zoukankan      html  css  js  c++  java
  • 黑盒测试等价类划分方法 续

    接上一篇,有三个输入框,都要求输入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 = "验证码输入不正确";
            }
        }
    }
    

     

  • 相关阅读:
    论工作动力的来源是什么?答案是来自于实现自己的梦想
    向梦想者致敬
    内置函数,递归函数,模块与包,开发目录规范
    迭代器,生成器
    闭包函数,装饰器,语法糖
    函数对象,名称空间及查找,作用域
    函数调用与参数
    字符编码
    文件处理
    python 11.5数据类型及常用方法
  • 原文地址:https://www.cnblogs.com/dengye/p/4376063.html
Copyright © 2011-2022 走看看