OTest2
A C++ testing framework
printutils.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2020 Ondrej Starek
3  *
4  * This file is part of OTest2
5  *
6  * OTest2 is free software: you can redistribute it and/or modify it under
7  * the terms of the GNU Lesser General Public License as published by
8  * the Free Software Foundation, either version 3 of the License,
9  * or (at your option) any later version.
10  *
11  * OTest2 is distributed in the hope that it will be useful, but WITHOUT
12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
14  * License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public License
17  * along with OTest2. If not, see <http://www.gnu.org/licenses/>.
18  */
19 #include <printutils.h>
20 
21 #include <iostream>
22 
23 namespace OTest2 {
24 
26  std::ostream& os_,
27  int number_) {
28  /* -- the number is always the same */
29  os_ << number_;
30 
31  /* -- resolve the suffix */
32  if(number_ > 10 && number_ < 20) {
33  os_ << "th";
34  }
35  else {
36  if(number_ < 0)
37  number_ *= -1;
38  switch(number_ % 10) {
39  case 1:
40  os_ << "st";
41  break;
42  case 2:
43  os_ << "nd";
44  break;
45  case 3:
46  os_ << "rd";
47  break;
48  default:
49  os_ << "th";
50  break;
51  }
52  }
53 }
54 
55 } /* -- namespace OTest2 */
printutils.h
OTest2
Definition: assertbean.h:25
OTest2::printOrdinalNumber
void printOrdinalNumber(std::ostream &os_, int number_)
Format the ordinal number with appropriate suffix.
Definition: printutils.cpp:25