---
# System prepended metadata

title: Software Testing HOMEWORK 1
tags: [ST, SoftwareTesting]

---

###### tags: `ST` `SoftwareTesting`
# Software Testing HOMEWORK 1
> 2020.05
> 0856040 王立洋

## public BoundedQueue(int capacity);
### a) List all of the input variables, including the state variables.
- capacity
### b) Define the characteristics of the input variables. Make sure you cover all input variables.
- capacity: int
    - Relation of capacity with 0
### c) Partition the characteristics into blocks. Designate one block in each partition as the "Base" block.
- A: Relation of capacity with 0
    - A1:`<0` A2:`=0` A3`>0`
### d) Define values for each block.
- A1: capacity=-1
- A2: capacity=0
- A3: capacity=5
### e) Define a test set that satisfies Base Choice Coverage (BCC). Write your tests with the values from the previous step. Be sure to include the test oracles.
- (A1): capacity=-1
    - ORACLES: IllegalArgumentException
- (A2): capacity=0
    - ORACLES: 
        - isEmpty() = true
        - isFull() = true
- (A3): capacity=5
    - ORACLES: 
        - isEmpty() = true
        - isFull() = false


## public void enQueue(Object o);
### a) List all of the input variables, including the state variables.
- o
- capacity
- back
- size
### b) Define the characteristics of the input variables. Make sure you cover all input variables.
- A: Object o is null
- B: size==capacity
- C: capacity is 1
### c) Partition the characteristics into blocks. Designate one block in each partition as the "Base" block.
- A: Object o is null
    - A0: False, A1: True
- B: size==capacity
    - B0: False, B1: True
- C: capacity is 1
    - C0: False, C1: True
- Base: (A0, B0, C0)
### d) Define values for each block.
- A: Object o is null
    - A0: `o="apple"`, A1: `o=null`
- B: size==capacity
    - B0: `size!=capacity`, B1: `size=capacity`
- C: capacity is 1
    - C0: `capacity=4`, C1: `capacity=1`

### e) Define a test set that satisfies Base Choice Coverage (BCC). Write your tests with the values from the previous step. Be sure to include the test oracles.
- Base: (A0, B0, C0)
- (A0, B0, C0)
    - capacity = 4
	- q.enQueue("apple");
	- q.enQueue("pen");
	- ORACLES: q="[apple, pen]"
- (A0, B0, C1)
    - capacity = 1
	- ORACLES: q="[]"
- (A0, B1, C0)
    - capacity = 4
	- q.enQueue("apple");
	- q.enQueue("pen");
	- q.enQueue("pineapple");
	- q.enQueue("applepen");
	- q.deQueue();
	- q.deQueue();
	- q.enQueue("A");
	- q.enQueue("B");
	- ORACLES: q="[pineapple, applepen, A, B]"
- (A0, B1, C1)
    - capacity = 1
	- q.enQueue("apple");
	- ORACLES: q="[apple]"
- (A1, ...Don't care)
    - o -> null
	- ORACLES: NullPointerException


## public Object deQueue();
### a) List all of the input variables, including the state variables.
- size
- front
- capacity
### b) Define the characteristics of the input variables. Make sure you cover all input variables.
- A: size==0
- B: front is the last in elements
### c) Partition the characteristics into blocks. Designate one block in each partition as the "Base" block.
- A: size==0
    - A0: False, A1: True
- B: front is the last in elements
    - B0: False, B1: True
- C: capacity is 1 [Precondition: B1]
    - C0: False, C1: True
- Base: (A0, B0, C0)
### d) Define values for each block.
- A: size==0
    - A0: `size!=0`, A1: `size=0`
- B: front is the last in elements
    - B0: `front!=capacity-1`, B1: `front=capacity-1`
- C: capacity is 1 [Precondition: B1]
    - C0: `capacity!=1`, C1: `capacity=1`
- Base: (A0, B0, C0)
### e) Define a test set that satisfies Base Choice Coverage (BCC). Write your tests with the values from the previous step. Be sure to include the test oracles.
- Base: (A0, B0, C0)
- (A0, B0, C0)
    - capacity = 4
	- q.enQueue("apple");
	- q.enQueue("pen");
	- q.enQueue("pineapple");
	- q.enQueue("applepen");
	- q.deQueue();
	- ORACLES: q="[pen, pineapple, applepen]"
- (A0, B1, C0)
    - capacity = 4
	- q.enQueue("apple");
	- q.enQueue("pen");
	- q.enQueue("pineapple");
	- q.enQueue("applepen");
	- q.deQueue();
	- q.deQueue();
	- q.deQueue();
	- q.enQueue("apple");
	- q.enQueue("pen");
	- ORACLES: q="[applepen, apple, pen]"
- (A0, B1, C1)
    - capacity = 1
	- q.enQueue("apple");
	- ORACLES: q="[applepen]"
- (A1, B0, C0) 
    - capacity = 4
	- q.enQueue("apple");
	- q.deQueue();
	- ORACLES: q="[applepen]"
- (A1, B1, C0) 
    - capacity = 4
	- q.enQueue("apple");
	- q.enQueue("pen");
	- q.enQueue("pineapple");
	- q.deQueue();
	- q.deQueue();
	- q.deQueue();
	- ORACLES: q="[]"


## public boolean isEmpty();
### a) List all of the input variables, including the state variables.
- size
### b) Define the characteristics of the input variables. Make sure you cover all input variables.
- A: size==0
### c) Partition the characteristics into blocks. Designate one block in each partition as the "Base" block.
- A: size==0
    - A0: False, A1: True
### d) Define values for each block.
- A: size==0
    - A0: `size!=0`, A1: `size=0`
### e) Define a test set that satisfies Base Choice Coverage (BCC). Write your tests with the values from the previous step. Be sure to include the test oracles.
- (A0)
    - capacity = 3
	- q.enQueue("apple");
	- q.enQueue("pen");
	- q.enQueue("pineapple");
	- ORACLES: q.isEmpty()=false
- (A1)
    - capacity = 3
	- ORACLES: q.isEmpty()=true


## public boolean isFull();
### a) List all of the input variables, including the state variables.
- size
- capacity
### b) Define the characteristics of the input variables. Make sure you cover all input variables.
- A: size==capacity
- B: capacity==1
### c) Partition the characteristics into blocks. Designate one block in each partition as the "Base" block.
- A: size==capacity
    - A0: False, A1: True
- B: capacity==1
    - B0: False, B1: True
- Base: (A1, B0)
### d) Define values for each block.
- A: size==capacity
    - A0: `size!=capacity`, A1: `size=capacity`
- B: capacity==1
    - B0: `capacity!=1`, B1: `capacity=1`
### e) Define a test set that satisfies Base Choice Coverage (BCC). Write your tests with the values from the previous step. Be sure to include the test oracles.
- Base: (A1, B0)
- (A1, B0)
    - capacity = 3
	- q.enQueue("apple");
	- q.enQueue("pen");
	- q.enQueue("pineapple");
	- ORACLES: q.isFull()=true
- (A1, B1)
    - capacity = 1
	- q.enQueue("apple");
	- ORACLES: q.isFull()=true
- (A0, B0)
    - capacity = 3
	- q.enQueue("apple");
	- ORACLES: q.isFull()=false














---