Skip to content

Commit c74c1e2

Browse files
authored
Merge pull request #47 from sir-gon/develop
BASIC: show limits of some types.
2 parents 147edaf + 06f0172 commit c74c1e2

File tree

3 files changed

+38
-0
lines changed

3 files changed

+38
-0
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#pragma once
2+
3+
namespace basic {
4+
5+
void limits();
6+
7+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#include <exercises/basic/limits.hpp>
2+
3+
#include <iostream>
4+
#include <limits>
5+
6+
namespace basic {
7+
8+
void limits() {
9+
std::cout << "type\t│ lowest()\t│ min()\t\t│ max()\n"
10+
<< "bool\t" << std::numeric_limits<bool>::lowest() << "\t\t"
11+
<< std::numeric_limits<bool>::min() << "\t\t"
12+
<< std::numeric_limits<bool>::max() << '\n'
13+
<< "uchar\t" << +std::numeric_limits<unsigned char>::lowest()
14+
<< "\t\t" << +std::numeric_limits<unsigned char>::min()
15+
<< "\t\t" << +std::numeric_limits<unsigned char>::max() << '\n'
16+
<< "int\t" << std::numeric_limits<int>::lowest() << "\t"
17+
<< std::numeric_limits<int>::min() << "\t"
18+
<< std::numeric_limits<int>::max() << '\n'
19+
<< "float\t" << std::numeric_limits<float>::lowest() << "\t"
20+
<< std::numeric_limits<float>::min() << "\t"
21+
<< std::numeric_limits<float>::max() << '\n'
22+
<< "double\t" << std::numeric_limits<double>::lowest() << "\t"
23+
<< std::numeric_limits<double>::min() << "\t"
24+
<< std::numeric_limits<double>::max() << '\n';
25+
}
26+
} // namespace basic
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#include <catch2/catch_test_macros.hpp>
2+
3+
#include <exercises/basic/limits.hpp>
4+
5+
TEST_CASE("limits", "[basic]") { basic::limits(); }

0 commit comments

Comments
 (0)