MCPcopy Create free account
hub / github.com/cpputest/cpputest / StringFromOrdinalNumber

Function StringFromOrdinalNumber

src/CppUTest/SimpleString.cpp:945–963  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

943}
944
945SimpleString StringFromOrdinalNumber(unsigned int number)
946{
947 unsigned int onesDigit = number % 10;
948
949 const char* suffix;
950 if (number >= 11 && number <= 13) {
951 suffix = "th";
952 } else if (3 == onesDigit) {
953 suffix = "rd";
954 } else if (2 == onesDigit) {
955 suffix = "nd";
956 } else if (1 == onesDigit) {
957 suffix = "st";
958 } else {
959 suffix = "th";
960 }
961
962 return StringFromFormat("%u%s", number, suffix);
963}
964
965SimpleStringCollection::SimpleStringCollection()
966{

Callers 2

TESTFunction · 0.85

Calls 1

StringFromFormatFunction · 0.85

Tested by 1

TESTFunction · 0.68