String Constraints
String assertions in Igloo are used to verify the values of STL strings (std::string).
Equality Constraints
Used to verify that actual is equal to an expected value.
Composite syntax: Assert:That(actual_str, Equals("foo"));
Fluent syntax: Assert::That(actual_str, Is().EqualTo("foo"));
Contains Constraint
Used to verify that a string contains a substring.
Composite syntax: Assert::That(actual_str, Contains("foo"));
Fluent syntax: Assert::That(actual_str, Is().Containing("foo"));
EndsWith Constraint
Used to verify that a string ends with an expected substring.
Composite syntax: Assert::That(actual_str, EndsWith("foo"));
Fluent syntax: Assert::That(actual_str, Is().EndingWith("foo"));
StartsWith Constraint
Used to verify that a string starts with an expected substring.
Composite syntax: Assert::That(actual_str, StartsWith("foo"));
Fluent syntax: Assert::That(actual_str, Is().StartingWith("foo"));
HasLength Constraint
Used to verify that a string is of the expected length.
Composite syntax: Assert::That(actual_str, HasLength(5));
Fluent syntax: Assert::That(actual_str, Is().OfLength(5));
Constraints on Multi Line Strings
If you have a string that contains multiple lines, you can use the collection constraints to make assertions on the content of that string. This may be handy if you have a string that, for instance, represents the resulting content of a file or a network transmission.
Igloo can handle both windows (CR+LF) and unix (LF) line endings