json_binder_value_double.t.h 712 B

1234567891011121314151617181920212223242526272829303132
  1. //
  2. // json_binder_value_double.t.h
  3. // json
  4. //
  5. // Created by Sam Jaffe on 2/25/17.
  6. //
  7. #pragma once
  8. #include <cxxtest/TestSuite.h>
  9. #include "json_binder.hpp"
  10. using namespace json::binder;
  11. using namespace json::parser;
  12. class json_binder_value_float_TestSuite : public CxxTest::TestSuite {
  13. public:
  14. void test_bind_to_double_type() {
  15. char data[] = "0.5";
  16. double out = 0.0;
  17. value_binder<double> binder{};
  18. parse(bind(out, binder), data, allow_all);
  19. TS_ASSERT_EQUALS(out, 0.5);
  20. }
  21. void test_parse_out_scientific_notation() {
  22. char data[] = "2e4";
  23. double out = 0.0;
  24. value_binder<double> binder{};
  25. TS_ASSERT_THROWS_NOTHING(parse(bind(out, binder), data, allow_all));
  26. }
  27. };