• 黑盒测试等价类划分方法 续


    接上一篇,有三个输入框,都要求输入1-6个英文字符或数字。

    测试用例:

    09aaaaa 不合法
    0+09 不合法
    009a 合法输入

    下面是测试结果:

      

    源代码如下:

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Windows.Forms;
    
    namespace WindowsFormsApplication2
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }
    
            private void button2_Click(object sender, EventArgs e)
            {
                textBox1.Text = "";
                textBox2.Text = "";
                textBox3.Text = "";
                label4.Text = "请先输入";
            }
    
            private void button1_Click_1(object sender, EventArgs e)
            {
                String[] str = new String[3];
    
                str[0] = textBox1.Text;
                str[1] = textBox2.Text;
                str[2] = textBox3.Text;
    
                Boolean res1 = System.Text.RegularExpressions.Regex.IsMatch(str[0], @"^[a-zA-Zd]{1,6}$");
                Boolean res2 = System.Text.RegularExpressions.Regex.IsMatch(str[1], @"^[a-zA-Zd]{1,6}$");
                Boolean res3 = System.Text.RegularExpressions.Regex.IsMatch(str[2], @"^[a-zA-Zd]{1,6}$");
    
                if (res1)
                    label4.Text = "用户名输入正确";
                else
                    label4.Text = "用户名输入不正确";
                if (res2)
                    label5.Text = "密码输入正确";
                else
                    label5.Text = "密码输入不正确";
                if (res3)
                    label6.Text = "验证码输入正确";
                else
                    label6.Text = "验证码输入不正确";
            }
        }
    }
    

     

  • 相关阅读:
    【c++】重载操作符
    关于Repository模式
    UML建模系列文章总结
    windows批量创建用户
    数据库数据导入导出系列之五 C#实现动态生成Word(转)
    C#.bat文件清理工程目录
    ASP.NET用HttpListener实现文件断点续传
    LINQ to JavaScript
    依赖注入框架Autofac的简单使用
    spring boot日期转换
  • 原文地址:https://www.cnblogs.com/dengye/p/4376063.html
Copyright © 2020-2023  润新知