How value comparison works

Value Comparison

This document specifies the rules to follow when comparing values returned by the System Under Test and the values expected by the field expert.

Comparing character strings

Rule 1 : String comparison is case sensitive

rule forstring comparison 
expected value system value equal? 
A string A string yes 
a mixed Case String A Mixed case stringno
a string another string no
"a string in quotes" a string in quotes yes

Comparing numbers

 Rule 2 : When comparing numeric values, leading zeros are ignored. When comparing decimal values, trailing zeros are ignored.

rule fornumber comparison 
expected value system value equal?
77yes
11.0yes
.150.15yes
0.11.0no
004242yes
-0.1-.1yes

Comparing boolean values

 Rule 3 : true and yes both represent the true value. no and false both represent the false value.  Comparison is case insensitive.

rule forboolean comparison
expected value system value equal?
truetrueyes
TRUEtrueyes
yestrueyes
true falseno
nofalse yes 

Comparing to a null value 

Rule 4 : We can specify that we expect a nil value using the keywords null and nothing.

rule fornull comparison 
expected value system value equal?
nullnullyes
nullany value no
nothingnullyes
any value nullno

Note : blank cell ...

Comparing to a type

Rule 5 : We can compare to a specific type (i.e. an instance of a class, an interface or a subclass of a class) using the name of the type.

rule fortype comparison
expected valuesystem value typeequal?
java.awt.Containerjava.awt.Containeryes
java.awt.Componentjava.lang.Stringno
java.awt.image.ImageObserverjava.lang.Stringno
Server is Headless (mandatory for this next example)
java.awt.Componentjava.awt.Buttonyes
java.awt.Buttonjava.awt.Containerno
java.awt.image.ImageObserverjava.awt.Buttonyes

 

Comparing to errors 

Rule 6 : We can use the keyword error when we expect an exception to occur within the system.

rule forerror comparison 
expected value system value equal?
anyjava.lang.Exceptionno
errorjava.lang.Throwableyes
erroranyno