ChaiScript / ChaiScript

@@ -996,6 +996,29 @@
Loading
996 996
}
997 997
998 998
999 +
TEST_CASE("Pair conversions")
1000 +
{
1001 +
  chaiscript::ChaiScript_Basic chai(create_chaiscript_stdlib(),create_chaiscript_parser());
1002 +
  chai.add(chaiscript::pair_conversion<std::string, std::string>());
1003 +
  chai.add(chaiscript::pair_conversion<int, double>());
1004 +
1005 +
  {
1006 +
    const auto p = chai.eval<std::pair<std::string, std::string>>(R"cs(
1007 +
      Pair("chai", "script");
1008 +
    )cs");
1009 +
    CHECK(p.first == std::string{"chai"});
1010 +
    CHECK(p.second == "script");
1011 +
  }
1012 +
  {
1013 +
    const auto p = chai.eval<std::pair<int, double>>(R"cs(
1014 +
      Pair(5, 3.14);
1015 +
    )cs");
1016 +
    CHECK(p.first == 5);
1017 +
    CHECK(p.second == Approx(3.14));
1018 +
  }
1019 +
}
1020 +
1021 +
999 1022
TEST_CASE("Parse floats with non-posix locale")
1000 1023
{
1001 1024
#ifdef CHAISCRIPT_MSVC

@@ -654,6 +654,23 @@
Loading
654 654
655 655
      return chaiscript::make_shared<detail::Type_Conversion_Base, detail::Type_Conversion_Impl<decltype(func)>>(user_type<std::map<std::string, Boxed_Value>>(), user_type<To>(), func);
656 656
    }
657 +
658 +
  template<typename Left, typename Right>
659 +
    Type_Conversion pair_conversion()
660 +
    {
661 +
      auto func = [](const Boxed_Value &t_bv) -> Boxed_Value {
662 +
        const std::pair<Boxed_Value, Boxed_Value> &from_pair = detail::Cast_Helper<const std::pair<Boxed_Value, Boxed_Value> &>::cast(t_bv, nullptr);
663 +
664 +
        auto pair = std::make_pair(
665 +
          detail::Cast_Helper<Left>::cast(from_pair.first, nullptr),
666 +
          detail::Cast_Helper<Right>::cast(from_pair.second, nullptr)
667 +
        );
668 +
669 +
        return Boxed_Value(std::move(pair));
670 +
      };
671 +
672 +
      return chaiscript::make_shared<detail::Type_Conversion_Base, detail::Type_Conversion_Impl<decltype(func)>>(user_type<std::pair<Boxed_Value, Boxed_Value>>(), user_type<std::pair<Left, Right>>(), func);
673 +
    }
657 674
}
658 675
659 676
Files Coverage
include/chaiscript 89.28%
src 72.79%
static_libs 100.00%
unittests 45.92%
Project Totals (60 files) 69.18%
1107.3
TRAVIS_OS_NAME=linux

No yaml found.

Create your codecov.yml to customize your Codecov experience

Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file. The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files. The size and color of each slice is representing the number of statements and the coverage, respectively.
Grid
Each block represents a single file in the project. The size and color of each block is represented by the number of statements and the coverage, respectively.
Loading