Null object or null reference in list

19 views
Skip to first unread message

Bilal Waqar

unread,
Mar 28, 2021, 7:29:37 PM3/28/21
to cofoja
Hi Group,

I am working on project to use cofoja to write contracts and I am stuck at place where I have to check if list is null or have null reference and no in world I can write pre condition for that.
This is my method: 
@Requires("n != null") 
public void push(Object o) {
numbers.add(o);
}
This is my test to check if I vioalte precondition
@Test 
public void PushFailTest () {
assertThrows(PreconditionError.class, () -> {
list.push(null);
});
}
Reply all
Reply to author
Forward
0 new messages