zoukankan      html  css  js  c++  java
  • 软件测试技术第二周课堂等价类习题

    有效等价类: 长度:1到6

             字符:a-z,A-Z,0-9

    无效等价类 长度:0,7

             字符:英文/数字以外字符,控制字符,标点符号

     

    部分代码如下:

    public void start(Stage stage)throws Exception {

       

            stage.setTitle("TEST");

            AnchorPane root = new AnchorPane();

            Scene scene = new Scene(root, 500, 300);

            scene.setFill(Color.WHITE);

           

            Text usename= new Text("用户名:");

            usename.setFont(Font.font ("Serif", 28));

            AnchorPane.setTopAnchor(usename, 100.0);

            AnchorPane.setLeftAnchor(usename, 50.0);

           

            Text tips= new Text("提示:");

            tips.setFont(Font.font ("Serif", 28));

            AnchorPane.setTopAnchor(tips, 150.0);

            AnchorPane.setLeftAnchor(tips, 50.0);

           

            final TextField textblock=new TextField();

            AnchorPane.setTopAnchor(textblock, 105.0);

            AnchorPane.setLeftAnchor(textblock, 200.0);

           

            final TextField textblock2=new TextField();

            AnchorPane.setTopAnchor(textblock2, 155.0);

            AnchorPane.setLeftAnchor(textblock2, 200.0);

           

            Button button = new Button("检验");

            AnchorPane.setTopAnchor(button, 105.0);

            AnchorPane.setRightAnchor(button, 50.0);

           

            button.setOnAction( new EventHandler<ActionEvent>( ) {

                public void handle(ActionEvent actEvt) {       

                    final String input;

                    input = textblock.getText();

                    if(input.length() > 6|| input.length() < 1){

                      textblock2.setText("er1:长度应为1-6");

                    }

                    else if(!isRegularRptCode(input,"[a-z,A-Z,0-9]*")){

                      textblock2.setText("er2: 字符应为a-z,A-Z,0-9");

                    }

                    else{

                      textblock2.setText("OK!!");

                    }

                }

            } );

            root.getChildren().addAll(usename,tips,textblock,textblock2,button);

            stage.setScene(scene);

            stage.show();

        }

    }

    结果截图:

                           

  • 相关阅读:
    Java数据类型转换(自动转换和强制转换)
    Java数据类型以及变量的定义
    Java8新特性_日期时间新类 LocalDate、LocalTime、LocalDateTime
    Java8新特性_接口中的默认方法
    java8 新特性 Optional容器类
    Java8新特性 并行流与串行流 Fork Join
    Java8新特性_stream API 练习
    IDEA导入JUnit4
    Reduce:规约;Collector:收集、判断性终止函数、组函数、分组、分区
    【Linux】排序命令sort
  • 原文地址:https://www.cnblogs.com/wangdongT-T/p/4357912.html
Copyright © 2011-2022 走看看