📄 pagstester.java
字号:
msg = "Testing " + tester3; assertTrue(msg, tester3.test(newPerson)); msg = "Testing " + tester4; assertFalse(msg, tester4.test(newPerson)); print("Success!"); print(CR + "***** LEAVING PAGSTester.testIntegerEQTester() *****" + CR);}/** */public void testIntegerGTTester() throws Exception{ print(CR + "***** ENTERING PAGSTester.testIntegerGTTester() *****" + CR); String msg = null; msg = "Creating a new IPerson"; print(msg); IPerson newPerson = getIPerson("de3"); assertNotNull(msg, newPerson); print("Adding attributes to IPerson."); newPerson.setAttribute(key1, randomIntStrings[0]); newPerson.setAttribute(key2, randomIntStrings[1]); newPerson.setAttribute(key3, intStringVector); msg = "Testing IPerson " + newPerson; print(msg); // test value == attribute value. Should answer false. IPersonTester tester1 = new IntegerGTTester(key1, randomIntStrings[0]); // test value < attribute value. Should answer true. IPersonTester tester2 = new IntegerGTTester(key2, "0"); // test value > any attribute value. Should answer false. IPersonTester tester3 = new IntegerGTTester(key3, INTEGER_MAX); // test value < any attribute value. Should answer true. IPersonTester tester4 = new IntegerGTTester(key3, "" + INTEGER_MIN); // attribute value not present. Should answer false. IPersonTester tester5 = new IntegerGTTester(missingKey, "0"); msg = "Testing " + tester1; assertFalse(msg, tester1.test(newPerson)); msg = "Testing " + tester2; assertTrue(msg, tester2.test(newPerson)); msg = "Testing " + tester3; assertFalse(msg, tester3.test(newPerson)); msg = "Testing " + tester4; assertTrue(msg, tester4.test(newPerson)); msg = "Testing " + tester5; assertFalse(msg, tester5.test(newPerson)); print("Success!"); print(CR + "***** LEAVING PAGSTester.testIntegerGTTester() *****" + CR);}public void testIntegerLTTester() throws Exception{ print(CR + "***** ENTERING PAGSTester.testIntegerLTTester() *****" + CR); String msg = null; msg = "Creating a new IPerson"; print(msg); IPerson newPerson = getIPerson("de3"); assertNotNull(msg, newPerson); print("Adding attributes to IPerson."); newPerson.setAttribute(key1, randomIntStrings[0]); newPerson.setAttribute(key2, randomIntStrings[1]); newPerson.setAttribute(key3, intStringVector); msg = "Testing IPerson " + newPerson; print(msg); // test value == attribute value. Should answer false. IPersonTester tester1 = new IntegerLTTester(key1, randomIntStrings[0]); // test value < attribute value. Should answer false. IPersonTester tester2 = new IntegerLTTester(key2, "0"); // test value > any attribute value. Should answer true. IPersonTester tester3 = new IntegerLTTester(key3, "" + INTEGER_MAX); // test value < any attribute value. Should answer false. IPersonTester tester4 = new IntegerLTTester(key3, "" + INTEGER_MIN); // test value > attribute value. Should answer true. IPersonTester tester5 = new IntegerLTTester(key1, "" + INTEGER_MAX); msg = "Testing " + tester1; assertFalse(msg, tester1.test(newPerson)); msg = "Testing " + tester2; assertFalse(msg, tester2.test(newPerson)); msg = "Testing " + tester3; assertTrue(msg, tester3.test(newPerson)); msg = "Testing " + tester4; assertFalse(msg, tester4.test(newPerson)); msg = "Testing " + tester5; assertTrue(msg, tester5.test(newPerson)); print("Success!"); print(CR + "***** LEAVING PAGSTester.testIntegerLTTester() *****" + CR);}public void testIntegerGETester() throws Exception{ print(CR + "***** ENTERING PAGSTester.testIntegerGETester() *****" + CR); String msg = null; msg = "Creating a new IPerson"; print(msg); IPerson newPerson = getIPerson("de3"); assertNotNull(msg, newPerson); print("Adding attributes to IPerson."); newPerson.setAttribute(key1, randomIntStrings[0]); newPerson.setAttribute(key2, randomIntStrings[1]); newPerson.setAttribute(key3, intStringVector); msg = "Testing IPerson " + newPerson; print(msg); // test value == attribute value. Should answer true. IPersonTester tester1 = new IntegerGETester(key1, randomIntStrings[0]); // test value < attribute value. Should answer true. IPersonTester tester2 = new IntegerGETester(key2, "0"); // test value > any attribute value. Should answer false. IPersonTester tester3 = new IntegerGETester(key3, "" + INTEGER_MAX); // test value < any attribute value. Should answer true. IPersonTester tester4 = new IntegerGETester(key3, "" + INTEGER_MIN); // test value > attribute value. Should answer false. IPersonTester tester5 = new IntegerGETester(key1, "" + INTEGER_MAX); msg = "Testing " + tester1; assertTrue(msg, tester1.test(newPerson)); msg = "Testing " + tester2; assertTrue(msg, tester2.test(newPerson)); msg = "Testing " + tester3; assertFalse(msg, tester3.test(newPerson)); msg = "Testing " + tester4; assertTrue(msg, tester4.test(newPerson)); msg = "Testing " + tester5; assertFalse(msg, tester5.test(newPerson)); print("Success!"); print(CR + "***** LEAVING PAGSTester.testIntegerGETester() *****" + CR);}public void testIntegerLETester() throws Exception{ print(CR + "***** ENTERING PAGSTester.testIntegerLETester() *****" + CR); String msg = null; msg = "Creating a new IPerson"; print(msg); IPerson newPerson = getIPerson("de3"); assertNotNull(msg, newPerson); print("Adding attributes to IPerson."); newPerson.setAttribute(key1, randomIntStrings[0]); newPerson.setAttribute(key2, randomIntStrings[1]); newPerson.setAttribute(key3, intStringVector); // test value == attribute value. Should answer true. IPersonTester tester1 = new IntegerLETester(key1, randomIntStrings[0]); // test value < attribute value. Should answer false. IPersonTester tester2 = new IntegerLETester(key2, "0"); // test value > any attribute value. Should answer true. IPersonTester tester3 = new IntegerLETester(key3, "" + INTEGER_MAX); // test value < any attribute value. Should answer false. IPersonTester tester4 = new IntegerLETester(key3, "" + INTEGER_MIN); // test value > attribute value. Should answer true. IPersonTester tester5 = new IntegerLETester(key1, "" + INTEGER_MAX); msg = "Testing IPerson " + newPerson; print(msg); msg = "Testing " + tester1; assertTrue(msg, tester1.test(newPerson)); msg = "Testing " + tester2; assertFalse(msg, tester2.test(newPerson)); msg = "Testing " + tester3; assertTrue(msg, tester3.test(newPerson)); msg = "Testing " + tester4; assertFalse(msg, tester4.test(newPerson)); msg = "Testing " + tester5; assertTrue(msg, tester5.test(newPerson)); print("Success!"); print(CR + "***** LEAVING PAGSTester.testIntegerLETester() *****" + CR);}public void testRegexTester() throws Exception{ print(CR + "***** ENTERING PAGSTester.testRegexTester() *****" + CR); String msg = null; msg = "Creating a new IPerson"; print(msg); IPerson newPerson = getIPerson("de3"); assertNotNull(msg, newPerson); print("Adding attributes to IPerson."); newPerson.setAttribute(key1, randomStrings[0]); newPerson.setAttribute(key2, randomStrings[1]); newPerson.setAttribute(key3, stringVector); msg = "Testing IPerson " + newPerson; print(msg); // test equals attribute. Should return true. IPersonTester tester1 = new RegexTester(key1, randomStrings[0]); // test and attribute begin with same String. Should return true. String testValue2 = randomStrings[0].substring(0,1) + ".*"; IPersonTester tester2 = new RegexTester(key1, testValue2); // test and attribute begin with different String. Should return false. String testValue3 = "^[0]"; IPersonTester tester3 = new RegexTester(key1, testValue3); // test and attribute end with same String. Should return true. String testValue4 = ".*" + randomStrings[1].substring(randomStrings[1].length() - 1) + "$"; IPersonTester tester4 = new RegexTester(key2, testValue4); // test and attribute end with different String. Should return false. String testValue5 = ".*9$"; IPersonTester tester5 = new RegexTester(key2, testValue5); // test value is same as last String in Vector. Should return true. String testValue6 = "^" + ((String)stringVector.lastElement()) + "$"; IPersonTester tester6 = new RegexTester(key3, testValue6); msg = "Testing " + tester1; assertTrue(msg, tester1.test(newPerson)); msg = "Testing " + tester2; assertTrue(msg, tester2.test(newPerson)); msg = "Testing " + tester3; assertFalse(msg, tester3.test(newPerson)); msg = "Testing " + tester4; assertTrue(msg, tester4.test(newPerson)); msg = "Testing " + tester5; assertFalse(msg, tester5.test(newPerson)); msg = "Testing " + tester6; assertTrue(msg, tester6.test(newPerson)); print("Success!"); print(CR + "***** LEAVING PAGSTester.testRegexTester() *****" + CR);}}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -