Parameter Value Coverage by Type
This article is a reference to Unit Testing with Parameter Value Coverage (PVC).
Primitive or Value Types
Short Name | .NET Class | Type | Width | Range (bits) |
---|---|---|---|---|
byte | Byte | Unsigned integer | 8 | 0 to 255 |
sbyte | SByte | Signed integer | 8 | -128 to 127 |
int | Int32 | Signed integer | 32 | -2,147,483,648 to 2,147,483,647 |
uint | UInt32 | Unsigned integer | 32 | 0 to 4294967295 |
short | Int16 | Signed integer | 16 | -32,768 to 32,767 |
ushort | UInt16 | Unsigned integer | 16 | 0 to 65535 |
long | Int64 | Signed integer | 64 | -9223372036854775808 to 9223372036854775807 |
ulong | UInt64 | Unsigned integer | 64 | 0 to 18446744073709551615 |
float | Single | Single-precision floating point type | 32 | -3.402823e38 to 3.402823e38 |
double | Double | Double-precision floating point type | 64 | -1.79769313486232e308 to 1.79769313486232e308 |
char | Char | A single Unicode character | 16 | Unicode symbols used in text |
bool | Boolean | Logical Boolean type | 8 | True or false |
object | Object | Base type of all other types | ||
string | String | A sequence of characters | ||
decimal | Decimal | Precise fractional or integral type that can represent decimal numbers with 29 significant digits | 128 | ±1.0 × 10e−28 to ±7.9 × 10e28 |
byte
- Zero, 0, which is also byte.MinValue.
- A positive byte between 0 and 255.
- byte.MaxValue or 255
sbyte
- Zero, 0, which is also sbyte.MinValue.
- A positive sbyte between 0 and 127.
- A negative sbyte between -128 and 0.
- sbyte.MaxValue or 127
- sbyte.MinValue or -128
int
- A positive int between 0 and 2,147,483,647
- A negative int between -2,147,483,648 and 0
- Zero, 0
- int.MaxValue or 2,147,483,647
- int.MinValue or -2,147,483,648
uint
- Zero, 0, which is also uint .MinValue.
- A positive uint between 0 and 4,294,967,295.
- uint .MaxValue or 4,294,967,295
short
- A positive short between 0 and 32,767
- A negative short between -32,768 and 0
- Zero, 0
- short.MaxValue or 32,767
- short.MinValue or -32,768
ushort
- Zero, 0, which is also ushort .MinValue.
- A positive ushort, such as 1 through 65,535.
- ushort.MaxValue or 65,535
long
- A positive long between 0 and 9,223,372,036,854,775,807
- A negative long between -9,223,372,036,854,775,808 and 0
- Zero, 0
- long.MaxValue or 9,223,372,036,854,775,807
- long.MinValue or -9,223,372,036,854,775,808
ulong
- Zero, 0, which is also ulong.MinValue.
- A positive ulong between 0 and 18,446,744,073,709,551,615.
- ulong.MaxValue or 18,446,744,073,709,551,615
float
- A positive float between 0 and 3.402823E+38
- Note: This includes the float.Epsilon, but you could test double.Epsilon separately
- A negative float between -3.402823E+38 and 0
- Zero, 0.0
- float.MaxValue or 3.402823E+38
- float.MinValue or -3.402823E+38
- float.NaN
- float.PositiveInfinity
- float.NegativeInfinity
double
- A positive double between 0 and 1.79769313486232E+308
- Note: This includes the double.Epsilon, but you could test double.Epsilon separately
- A negative double between -1.79769313486232E+308 and 0
- Zero, 0.0
- double.MaxValue or 1.79769313486232E+308
- double.MinValue or -1.79769313486232E+308
- double.NaN
- double.PositiveInfinity
- double.NegativeInfinity
decimal
- A positive double between 0 and 79,228,162,514,264,337,593,543,950,335
- A negative double between -79,228,162,514,264,337,593,543,950,335 and 0
- Zero, 0
- double.MaxValue or 79,228,162,514,264,337,593,543,950,335
- double.MinValue or -79,228,162,514,264,337,593,543,950,335
string
- A null string
- An empty string, String.Empty, or “”
- One or more spaces ” “
- One or more tabs ” “
- A new line or Environment.NewLine
- A valid string.
- An invalid or junk string
- A string with many special characters: `~!@#$%^&*()_-+=,.<>/\?[]{}|
- Unicode characters such as Chinese
- An long string, over 256 characters, or even 1 million characters.
- (Occasionally) Case sensitivity. For example, for string comparisons, case sensitivity of a string is a required Parameter Value Coverage test.
Struct
- This one takes thought. You need to define this per struct you create. For example, if your struct is a point with int values X and Y, then it is simply the int list above twice, once for X and once for Y.
Enum
- Any of the enums.
- You may need to do each of the enums, depending on how your enum is used.
Class or Reference Types
Class Object
Objects that are defined with the class keyword need the following tested:
- Null (This might go away or become optional in .NET 4.8)
- Instantiated
- Class properties can be primitive or value types, reference types, etc., and may need to be tested according to the type of the property.
Array, List, Dictionary, and other collections
Array, List, Collection
- Null
- Empty (instantiated with no items)
- Not empty but values of array are tested according to the value type. For example, an int[] would need to have the values tested in the ways listed above for int.
- Pay attention to how the code you are testing uses teh items in an array or list. If the items are objects, do you need to check if the list has a null item in the list?
Dictionary
- Null
- Empty (instantiated with no items)
- Key exists
- Key doesn’t exist
- Value at key is tested according to its value type. For example, a Dictionary<string, int> would need to have the values tested in the ways listed above for int.