File: test_double.cpp

package info (click to toggle)
libosmium 2.23.0-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 4,564 kB
  • sloc: cpp: 53,570; sh: 148; makefile: 19
file content (32 lines) | stat: -rw-r--r-- 648 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include "catch.hpp"

#include <osmium/util/double.hpp>

#include <string>

TEST_CASE("Check double2string function") {
    std::string s1;
    osmium::double2string(s1, 1.123, 7);
    REQUIRE(s1 == "1.123");

    std::string s2;
    osmium::double2string(s2, 1.000, 7);
    REQUIRE(s2 == "1");

    std::string s3;
    osmium::double2string(s3, 0.0, 7);
    REQUIRE(s3 == "0");

    std::string s4;
    osmium::double2string(s4, 0.020, 7);
    REQUIRE(s4 == "0.02");

    std::string s5;
    osmium::double2string(s5, -0.020, 7);
    REQUIRE(s5 == "-0.02");

    std::string s6;
    osmium::double2string(s6, -0.0, 7);
    REQUIRE(s6 == "-0");
}