Skip to content

Commit

Permalink
Merge pull request #47 from sir-gon/develop
Browse files Browse the repository at this point in the history
BASIC:  show limits of some types.
  • Loading branch information
sir-gon authored Sep 25, 2024
2 parents 147edaf + 06f0172 commit c74c1e2
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/lib/exercises/include/exercises/basic/limits.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#pragma once

namespace basic {

void limits();

}
26 changes: 26 additions & 0 deletions src/lib/exercises/src/basic/limits.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#include <exercises/basic/limits.hpp>

#include <iostream>
#include <limits>

namespace basic {

void limits() {
std::cout << "type\t│ lowest()\t│ min()\t\t│ max()\n"
<< "bool\t" << std::numeric_limits<bool>::lowest() << "\t\t"
<< std::numeric_limits<bool>::min() << "\t\t"
<< std::numeric_limits<bool>::max() << '\n'
<< "uchar\t" << +std::numeric_limits<unsigned char>::lowest()
<< "\t\t" << +std::numeric_limits<unsigned char>::min()
<< "\t\t" << +std::numeric_limits<unsigned char>::max() << '\n'
<< "int\t" << std::numeric_limits<int>::lowest() << "\t"
<< std::numeric_limits<int>::min() << "\t"
<< std::numeric_limits<int>::max() << '\n'
<< "float\t" << std::numeric_limits<float>::lowest() << "\t"
<< std::numeric_limits<float>::min() << "\t"
<< std::numeric_limits<float>::max() << '\n'
<< "double\t" << std::numeric_limits<double>::lowest() << "\t"
<< std::numeric_limits<double>::min() << "\t"
<< std::numeric_limits<double>::max() << '\n';
}
} // namespace basic
5 changes: 5 additions & 0 deletions src/tests/unit/lib/basic/limits.test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#include <catch2/catch_test_macros.hpp>

#include <exercises/basic/limits.hpp>

TEST_CASE("limits", "[basic]") { basic::limits(); }

0 comments on commit c74c1e2

Please sign in to comment.