瀏覽代碼

feat: import from pokemon/300c7bd1ee37e25c62dc00344016bf85fd7367ba

refactor: using string-utils, ADL
Sam Jaffe 2 年之前
父節點
當前提交
d2c5d43b4a

+ 6 - 0
.gitmodules

@@ -0,0 +1,6 @@
+[submodule "external/string-utils"]
+	path = external/string-utils
+	url = ssh://git@gogs.sjaffe.name:3000/sjjaffe/cpp-string-utils.git
+[submodule "external/magic_enum"]
+	path = external/magic_enum
+	url = https://github.com/Neargye/magic_enum.git

+ 1 - 0
external/magic_enum

@@ -0,0 +1 @@
+Subproject commit e1a68e9dd3d2e9180b04c8aeacd4975db745e6b8

+ 1 - 0
external/string-utils

@@ -0,0 +1 @@
+Subproject commit a66ac70c36b4c52a7f6ddf5bc0118892ad8175ca

+ 13 - 0
include/serializer/forwards.h

@@ -0,0 +1,13 @@
+//
+//  forwards.h
+//  serializer
+//
+//  Created by Sam Jaffe on 3/15/23.
+//
+
+#pragma once
+
+namespace serializer {
+class Jsonizer;
+class SharedCache;
+}

+ 103 - 0
include/serializer/jsonizer.h

@@ -0,0 +1,103 @@
+//
+//  jsonizer.h
+//  serializer
+//
+//  Created by Sam Jaffe on 3/15/23.
+//
+
+#pragma once
+
+#include <iosfwd>
+#include <memory>
+#include <string>
+
+#include <json/forwards.h>
+
+#include <serializer/forwards.h>
+
+namespace serializer {
+
+class Jsonizer {
+public:
+  template <typename T> Json::Value to_json(T const & value) const;
+  template <typename T>
+  void from_json(T & value, Json::Value const & json) const;
+  template <typename T> T from_json(Json::Value const & json) const;
+  /**
+   * @brief Load an object from either JSON, or from p_cache, depending on
+   * the structure of the inputs.
+   * @param ptr A pointer to an uninstantiated value
+   * @param json A JSON object or string. If json is a string, then we attempt
+   * to load ptr from p_cache, according to {@see Json::Value::asString}. If
+   * json is an object, then we instead construct it like normal and attempt
+   * to store the new object in p_cache.
+   * @throws If json.isString() and T is not a recognized type in shared_cache
+   * then this function will throw according to {@see shared_cache::fetch}.
+   */
+  template <typename T>
+  void from_json(std::shared_ptr<T const> & ptr,
+                 Json::Value const & json) const;
+
+  /**
+   * @brief Construct an object of type 'T' from a datastream
+   * @param T the output type to be deserialized
+   * @param in A stream of JSON data
+   * @return A newly constructed object by value
+   */
+  template <typename T> T from_stream(std::istream & in) const;
+  template <typename T> T from_string(std::string const & in) const;
+  /**
+   * @brief Write an object out to a datastream, such as std::cout or a file
+   * @param T the input type to be serialized
+   * @param value The instance of type T to serialize
+   * @param out an output stream of any sort
+   */
+  template <typename T>
+  void to_stream(T const & value, std::ostream & out) const;
+  /**
+   * @brief Construct an object of type 'T' from a file handle
+   * @param T the output type to be deserialized
+   * @param file the name of a JSON file on disk to be read
+   * @return A newly constructed object by value
+   */
+  template <typename T> T from_file(std::string const & file) const;
+
+  /**
+   * @brief Construct a jsonizer with a personal instance of the data cache.
+   * Because there is no getter for p_cache, all cached instances are locally
+   * stored, meaning that each jsonizer default-constructed will have a
+   * different state of the cache.
+   */
+  Jsonizer();
+  /**
+   * @brief Construct a jsonizer with an externally owned cache
+   * @param cache A shared_ptr to a data cache. Cannot be null
+   * @throws std::logic_error if cache == nullptr
+   */
+  Jsonizer(std::shared_ptr<SharedCache> cache);
+  /**
+   * Do not permit the construction of a jsonizer from a nullptr literal.
+   * This moves the run-time exception std::logic_error to compiler time.
+   */
+  Jsonizer(std::nullptr_t) = delete;
+
+private:
+  template <typename T, size_t... Is>
+  Json::Value to_json(T & value, std::index_sequence<Is...>) const;
+  template <typename T, size_t... Is>
+  void from_json(T & value, Json::Value const & json,
+                 std::index_sequence<Is...>) const;
+
+  template <typename T> Json::Value to_json_impl(T const & value) const;
+  template <typename T>
+  void from_json_impl(T & value, Json::Value const & json) const;
+
+  template <typename T, typename F>
+  T from_cached_json(std::string const & key, Json::Value const & json,
+                     F && fetch) const;
+
+private:
+  std::shared_ptr<SharedCache> p_cache;
+};
+
+}

+ 154 - 0
include/serializer/jsonizer.tpp

@@ -0,0 +1,154 @@
+//
+//  jsonizer.tpp
+//  serializer
+//
+//  Created by Sam Jaffe on 3/15/23.
+//
+
+#pragma once
+
+#include <fstream>
+#include <iostream>
+#include <stdexcept>
+
+#include <json/json.h>
+#include <magic_enum.hpp>
+
+#include <serializer/jsonizer.h>
+#include <serializer/traits.h>
+
+namespace serializer {
+template <typename T, size_t... Is>
+Json::Value Jsonizer::to_json(T & value, std::index_sequence<Is...>) const {
+  Json::Value json;
+  [[maybe_unused]] auto l = {
+      ((json[int(Is)] = to_json(std::get<Is>(value))), 0)...};
+  return json;
+}
+
+template <typename T> Json::Value Jsonizer::to_json(T const & value) const {
+  if constexpr (detail::has_serial_type_v<T>) {
+    return to_json(static_cast<typename T::serial_type>(value));
+  } else if constexpr (std::is_enum_v<T>) {
+    return magic_enum::enum_name(value);
+  } else if constexpr (detail::is_tuple_v<T>) {
+    return to_json(value, std::make_index_sequence<std::tuple_size_v<T>>());
+  } else if constexpr (std::is_same_v<T, std::string>) {
+    return value;
+  } else if constexpr (std::is_floating_point_v<T>) {
+    return static_cast<double>(value);
+  } else if constexpr (std::is_arithmetic_v<T>) {
+    return static_cast<int>(value);
+  } else if constexpr (detail::is_associative_container_v<T>) {
+    Json::Value rval;
+    using K = std::decay_t<typename T::key_type>;
+    if constexpr (std::is_same_v<std::string, K> || std::is_arithmetic_v<K>) {
+      for (auto const & [k, v] : value) {
+        rval[to_string(k)] = to_json(v);
+      }
+    } else {
+      for (auto const & pair : value) {
+        rval.append(to_json(pair));
+      }
+    }
+    return rval;
+  } else if constexpr (detail::is_container_v<T>) {
+    Json::Value rval;
+    for (auto const & elem : value) {
+      rval.append(to_json(elem));
+    }
+    return rval;
+  } else {
+    return to_json_impl(value);
+  }
+}
+
+template <typename T, size_t... Is>
+void Jsonizer::from_json(T & value, Json::Value const & json,
+                         std::index_sequence<Is...>) const {
+  [[maybe_unused]] auto l = {
+      ((std::get<Is>(value) =
+            from_json<std::tuple_element_t<Is, T>>(json[int(Is)])),
+       0)...};
+}
+
+template <typename T>
+void Jsonizer::from_json(T & value, Json::Value const & json) const {
+  if (json.isNull()) return;
+  if constexpr (detail::has_serial_type_v<T>) {
+    value = T(from_json<typename T::serial_type>(json));
+  } else if constexpr (std::is_enum_v<T>) {
+    if (!from_string(value, json.asString())) {
+      throw std::invalid_argument("Cannot cast to enum: " + json.asString());
+    }
+  } else if constexpr (std::is_same_v<std::string, T>) {
+    value = json.asString();
+  } else if constexpr (detail::is_tuple_v<T>) {
+    from_json(value, json, std::make_index_sequence<std::tuple_size_v<T>>());
+  } else if constexpr (detail::is_associative_container_v<T>) {
+    using K = std::decay_t<typename T::key_type>;
+    using V = std::decay_t<typename T::mapped_type>;
+    if (json.isArray()) {
+      std::vector<std::pair<K, V>> tmp;
+      from_json(tmp, json);
+      value.insert(tmp.begin(), tmp.end());
+    } else if (json.isObject()) {
+      if constexpr (std::is_constructible_v<K, std::string>) {
+        for (auto it = json.begin(), end = json.end(); it != end; ++it) {
+          value.emplace(it.key().asString(), from_json<V>(*it));
+        }
+      } else {
+        for (auto it = json.begin(), end = json.end(); it != end; ++it) {
+          value.emplace(from_string<K>(it.key().asString()), from_json<V>(*it));
+        }
+      }
+    } else {
+      throw std::invalid_argument(
+          "cannot construct container from non-container");
+    }
+  } else if constexpr (detail::is_container_v<T>) {
+    using V = std::decay_t<typename T::value_type>;
+    if (!json.isArray()) {
+      throw std::invalid_argument("cannot construct container from non-array");
+    }
+    for (auto const & elem : json) {
+      value.insert(value.end(), from_json<V>(elem));
+    }
+  } else if constexpr (std::is_floating_point_v<T>) {
+    value = static_cast<T>(json.asDouble());
+  } else if constexpr (std::is_arithmetic_v<T>) {
+    value = static_cast<T>(json.asInt());
+  } else {
+    from_json_impl(value, json);
+  }
+}
+
+template <typename T> T Jsonizer::from_json(Json::Value const & json) const {
+  std::decay_t<T> tmp;
+  from_json(tmp, json);
+  return tmp;
+}
+
+template <typename T> T Jsonizer::from_stream(std::istream & in) const {
+  Json::Value root;
+  in >> root;
+  return from_json<T>(root);
+}
+
+template <typename T> T Jsonizer::from_string(std::string const & in) const {
+  std::stringstream ss;
+  ss << in;
+  return from_stream<T>(ss);
+}
+
+template <typename T>
+void Jsonizer::to_stream(T const & value, std::ostream & out) const {
+  Json::Value root = to_json(value);
+  out << root;
+}
+
+template <typename T> T Jsonizer::from_file(std::string const & file) const {
+  std::ifstream in(file);
+  return from_stream<T>(in);
+}
+}

+ 51 - 0
include/serializer/shared_cache.h

@@ -0,0 +1,51 @@
+//
+//  shared_cache.h
+//  serializer
+//
+//  Created by Sam Jaffe on 3/15/23.
+//
+
+#pragma once
+
+#include <memory>
+#include <string>
+
+namespace serializer {
+class SharedCache {
+public:
+  using Key = std::string;
+  template <typename T> using Record = std::shared_ptr<T const>;
+
+public:
+  SharedCache();
+  ~SharedCache();
+
+  /**
+   * @brief Store an object within this cache, returning a pointer to the
+   * cached object. In order to be nullptr-safe, the unspecialized version
+   * of this function returns a shared_ptr containing a copy of value.
+   * Specialized versions exist in shared_cache.cxx, which actually perform
+   * caching.
+   * @param key The name of the value, for looking up later
+   * @param value The value to store within this cache
+   * @return A shared_ptr containing the cached value
+   */
+  template <typename T> Record<T> store(Key const & key, T const & value) {
+    return std::make_shared<T>(value);
+  }
+  /**
+   * @brief Fetch an object that was cached within this object.
+   * @param key The name of the cached object, as called in store()
+   * @return A shared_ptr containing the requested object, or null if it isn't
+   * found in this cache.
+   * @throws std::domain_error if no specialization is defined
+   */
+  template <typename T> Record<T> fetch(Key const & key) const {
+    throw std::domain_error(typeid(T).name());
+  }
+
+private:
+  struct Impl;
+  std::unique_ptr<Impl> p_impl;
+};
+}

+ 32 - 0
include/serializer/strconv.h

@@ -0,0 +1,32 @@
+//
+//  stringizer.h
+//  serializer
+//
+//  Created by Sam Jaffe on 3/15/23.
+//
+
+#pragma once
+
+#include <string>
+#include <string_view>
+#include <type_traits>
+
+#include <magic_enum.hpp>
+
+#include <serializer/traits.h>
+
+namespace serializer {
+using ::std::to_string;
+inline std::string to_string(char const *str) { return str; }
+inline std::string to_string(std::string const &str) { return str; }
+inline std::string to_string(std::string_view str) { return std::string(str); }
+template <typename T> std::string to_string(T const * t) { return to_string(*t); }
+
+template <typename T> std::string to_string(T const &elem) {
+  if constexpr (std::is_enum_v<T>) {
+    return std::string(magic_enum::enum_name(value));
+  } else {
+    static_assert(detail::always_false<T>{});
+  }
+}
+}

+ 45 - 0
include/serializer/traits.h

@@ -0,0 +1,45 @@
+//
+//  traits.h
+//  serializer
+//
+//  Created by Sam Jaffe on 3/15/23.
+//
+
+#pragma once
+
+namespace serializer::detail {
+template <typename> struct always_false : std::false_type {};
+
+// Don't capture Aggregate objects lol...
+template <typename, typename = void> struct is_tuple : std::false_type {};
+template <typename K, typename V>
+struct is_tuple<std::pair<K, V>> : std::true_type {};
+template <typename T, size_t N>
+struct is_tuple<std::array<T, N>> : std::true_type {};
+template <typename... Ts>
+struct is_tuple<std::tuple<Ts...>> : std::true_type {};
+
+template <typename, typename = void> struct is_container : std::false_type {};
+template <typename T>
+struct is_container<T, std::void_t<typename T::value_type>> : std::true_type {};
+
+template <typename, typename = void>
+struct is_associative_container : std::false_type {};
+template <typename T>
+struct is_associative_container<T, std::void_t<typename T::mapped_type>>
+    : std::true_type {};
+
+template <typename, typename = void>
+struct has_serial_type : std::false_type {};
+template <typename T>
+struct has_serial_type<T, std::void_t<typename T::serial_type>>
+    : std::true_type {};
+
+template <typename T> constexpr bool is_tuple_v = is_tuple<T>{};
+template <typename T> constexpr bool is_container_v = is_container<T>{};
+template <typename T>
+constexpr bool is_associative_container_v =
+    is_container_v<T> && is_associative_container<T>{};
+
+template <typename T> constexpr bool has_serial_type_v = has_serial_type<T>{};
+}

+ 583 - 0
serializer.xcodeproj/project.pbxproj

@@ -0,0 +1,583 @@
+// !$*UTF8*$!
+{
+	archiveVersion = 1;
+	classes = {
+	};
+	objectVersion = 55;
+	objects = {
+
+/* Begin PBXBuildFile section */
+		CD592C0F29C3D932009AC14E /* serializer in Headers */ = {isa = PBXBuildFile; fileRef = CD592C0629C2A5EB009AC14E /* serializer */; settings = {ATTRIBUTES = (Public, ); }; };
+		CD592C2229C3DB79009AC14E /* jsonizer_test.cxx in Sources */ = {isa = PBXBuildFile; fileRef = CD592C2129C3DB79009AC14E /* jsonizer_test.cxx */; };
+		CD592C2729C3DC65009AC14E /* libjsoncpp.a in Frameworks */ = {isa = PBXBuildFile; fileRef = CD592C2629C3DC65009AC14E /* libjsoncpp.a */; };
+/* End PBXBuildFile section */
+
+/* Begin PBXContainerItemProxy section */
+		CD592C1C29C3DB32009AC14E /* PBXContainerItemProxy */ = {
+			isa = PBXContainerItemProxy;
+			containerPortal = CD592BF529C2A5BF009AC14E /* Project object */;
+			proxyType = 1;
+			remoteGlobalIDString = CD592BFC29C2A5BF009AC14E;
+			remoteInfo = serializer;
+		};
+		CD592C2F29C3DC76009AC14E /* PBXContainerItemProxy */ = {
+			isa = PBXContainerItemProxy;
+			containerPortal = CD592C2829C3DC76009AC14E /* GoogleMock.xcodeproj */;
+			proxyType = 2;
+			remoteGlobalIDString = 05818F861A685AEA0072A469;
+			remoteInfo = GoogleMock;
+		};
+		CD592C3129C3DC76009AC14E /* PBXContainerItemProxy */ = {
+			isa = PBXContainerItemProxy;
+			containerPortal = CD592C2829C3DC76009AC14E /* GoogleMock.xcodeproj */;
+			proxyType = 2;
+			remoteGlobalIDString = 05E96ABD1A68600C00204102;
+			remoteInfo = gmock;
+		};
+		CD592C3329C3DC76009AC14E /* PBXContainerItemProxy */ = {
+			isa = PBXContainerItemProxy;
+			containerPortal = CD592C2829C3DC76009AC14E /* GoogleMock.xcodeproj */;
+			proxyType = 2;
+			remoteGlobalIDString = 05E96B1F1A68634900204102;
+			remoteInfo = gtest;
+		};
+		CD592C3529C3DC76009AC14E /* PBXContainerItemProxy */ = {
+			isa = PBXContainerItemProxy;
+			containerPortal = CD592C2829C3DC76009AC14E /* GoogleMock.xcodeproj */;
+			proxyType = 2;
+			remoteGlobalIDString = 05818F901A685AEA0072A469;
+			remoteInfo = GoogleMockTests;
+		};
+		CD592C3D29C3DC85009AC14E /* PBXContainerItemProxy */ = {
+			isa = PBXContainerItemProxy;
+			containerPortal = CD592C3729C3DC84009AC14E /* string-utils.xcodeproj */;
+			proxyType = 2;
+			remoteGlobalIDString = CD266862252FF4B600B3E667;
+			remoteInfo = "string-utils";
+		};
+		CD592C3F29C3DC85009AC14E /* PBXContainerItemProxy */ = {
+			isa = PBXContainerItemProxy;
+			containerPortal = CD592C3729C3DC84009AC14E /* string-utils.xcodeproj */;
+			proxyType = 2;
+			remoteGlobalIDString = CD266886252FFAAE00B3E667;
+			remoteInfo = "string_utils-test";
+		};
+/* End PBXContainerItemProxy section */
+
+/* Begin PBXFileReference section */
+		CD592BFD29C2A5BF009AC14E /* libserializer.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libserializer.a; sourceTree = BUILT_PRODUCTS_DIR; };
+		CD592C0629C2A5EB009AC14E /* serializer */ = {isa = PBXFileReference; lastKnownFileType = folder; name = serializer; path = include/serializer; sourceTree = "<group>"; };
+		CD592C0729C2A607009AC14E /* jsonizer.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = jsonizer.h; sourceTree = "<group>"; };
+		CD592C0829C2A610009AC14E /* jsonizer.tpp */ = {isa = PBXFileReference; lastKnownFileType = text; path = jsonizer.tpp; sourceTree = "<group>"; };
+		CD592C0929C2A63A009AC14E /* shared_cache.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = shared_cache.h; sourceTree = "<group>"; };
+		CD592C0A29C2A64C009AC14E /* strconv.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = strconv.h; sourceTree = "<group>"; };
+		CD592C0B29C2A6C8009AC14E /* forwards.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = forwards.h; sourceTree = "<group>"; };
+		CD592C0C29C2A707009AC14E /* traits.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = traits.h; sourceTree = "<group>"; };
+		CD592C1729C3DB32009AC14E /* serializer-test.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "serializer-test.xctest"; sourceTree = BUILT_PRODUCTS_DIR; };
+		CD592C2129C3DB79009AC14E /* jsonizer_test.cxx */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = jsonizer_test.cxx; sourceTree = "<group>"; };
+		CD592C2429C3DBB7009AC14E /* xcode_gtest_helper.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = xcode_gtest_helper.h; sourceTree = "<group>"; };
+		CD592C2629C3DC65009AC14E /* libjsoncpp.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libjsoncpp.a; path = ../../../../../../../../opt/local/lib/libjsoncpp.a; sourceTree = "<group>"; };
+		CD592C2829C3DC76009AC14E /* GoogleMock.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = GoogleMock.xcodeproj; path = "../../../gmock-xcode-master/GoogleMock.xcodeproj"; sourceTree = "<group>"; };
+		CD592C3729C3DC84009AC14E /* string-utils.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = "string-utils.xcodeproj"; path = "external/string-utils/string-utils.xcodeproj"; sourceTree = "<group>"; };
+/* End PBXFileReference section */
+
+/* Begin PBXFrameworksBuildPhase section */
+		CD592BFB29C2A5BF009AC14E /* Frameworks */ = {
+			isa = PBXFrameworksBuildPhase;
+			buildActionMask = 2147483647;
+			files = (
+			);
+			runOnlyForDeploymentPostprocessing = 0;
+		};
+		CD592C1429C3DB32009AC14E /* Frameworks */ = {
+			isa = PBXFrameworksBuildPhase;
+			buildActionMask = 2147483647;
+			files = (
+				CD592C2729C3DC65009AC14E /* libjsoncpp.a in Frameworks */,
+			);
+			runOnlyForDeploymentPostprocessing = 0;
+		};
+/* End PBXFrameworksBuildPhase section */
+
+/* Begin PBXGroup section */
+		CD592BF429C2A5BF009AC14E = {
+			isa = PBXGroup;
+			children = (
+				CD592C2829C3DC76009AC14E /* GoogleMock.xcodeproj */,
+				CD592C3729C3DC84009AC14E /* string-utils.xcodeproj */,
+				CD592C0629C2A5EB009AC14E /* serializer */,
+				CD592C0429C2A5E0009AC14E /* include */,
+				CD592C1229C3DB22009AC14E /* test */,
+				CD592C1829C3DB32009AC14E /* serializer-test */,
+				CD592BFE29C2A5BF009AC14E /* Products */,
+				CD592C2529C3DC64009AC14E /* Frameworks */,
+			);
+			sourceTree = "<group>";
+		};
+		CD592BFE29C2A5BF009AC14E /* Products */ = {
+			isa = PBXGroup;
+			children = (
+				CD592BFD29C2A5BF009AC14E /* libserializer.a */,
+				CD592C1729C3DB32009AC14E /* serializer-test.xctest */,
+			);
+			name = Products;
+			sourceTree = "<group>";
+		};
+		CD592C0429C2A5E0009AC14E /* include */ = {
+			isa = PBXGroup;
+			children = (
+				CD592C0529C2A5E0009AC14E /* serializer */,
+			);
+			path = include;
+			sourceTree = "<group>";
+		};
+		CD592C0529C2A5E0009AC14E /* serializer */ = {
+			isa = PBXGroup;
+			children = (
+				CD592C0B29C2A6C8009AC14E /* forwards.h */,
+				CD592C0729C2A607009AC14E /* jsonizer.h */,
+				CD592C0829C2A610009AC14E /* jsonizer.tpp */,
+				CD592C0929C2A63A009AC14E /* shared_cache.h */,
+				CD592C0A29C2A64C009AC14E /* strconv.h */,
+				CD592C0C29C2A707009AC14E /* traits.h */,
+			);
+			path = serializer;
+			sourceTree = "<group>";
+		};
+		CD592C1229C3DB22009AC14E /* test */ = {
+			isa = PBXGroup;
+			children = (
+				CD592C2429C3DBB7009AC14E /* xcode_gtest_helper.h */,
+				CD592C2129C3DB79009AC14E /* jsonizer_test.cxx */,
+			);
+			path = test;
+			sourceTree = "<group>";
+		};
+		CD592C1829C3DB32009AC14E /* serializer-test */ = {
+			isa = PBXGroup;
+			children = (
+			);
+			path = "serializer-test";
+			sourceTree = "<group>";
+		};
+		CD592C2529C3DC64009AC14E /* Frameworks */ = {
+			isa = PBXGroup;
+			children = (
+				CD592C2629C3DC65009AC14E /* libjsoncpp.a */,
+			);
+			name = Frameworks;
+			sourceTree = "<group>";
+		};
+		CD592C2929C3DC76009AC14E /* Products */ = {
+			isa = PBXGroup;
+			children = (
+				CD592C3029C3DC76009AC14E /* GoogleMock.framework */,
+				CD592C3229C3DC76009AC14E /* gmock.framework */,
+				CD592C3429C3DC76009AC14E /* gtest.framework */,
+				CD592C3629C3DC76009AC14E /* GoogleMockTests.xctest */,
+			);
+			name = Products;
+			sourceTree = "<group>";
+		};
+		CD592C3829C3DC84009AC14E /* Products */ = {
+			isa = PBXGroup;
+			children = (
+				CD592C3E29C3DC85009AC14E /* libstring-utils.a */,
+				CD592C4029C3DC85009AC14E /* string_utils-test.xctest */,
+			);
+			name = Products;
+			sourceTree = "<group>";
+		};
+/* End PBXGroup section */
+
+/* Begin PBXHeadersBuildPhase section */
+		CD592BF929C2A5BF009AC14E /* Headers */ = {
+			isa = PBXHeadersBuildPhase;
+			buildActionMask = 2147483647;
+			files = (
+				CD592C0F29C3D932009AC14E /* serializer in Headers */,
+			);
+			runOnlyForDeploymentPostprocessing = 0;
+		};
+/* End PBXHeadersBuildPhase section */
+
+/* Begin PBXNativeTarget section */
+		CD592BFC29C2A5BF009AC14E /* serializer */ = {
+			isa = PBXNativeTarget;
+			buildConfigurationList = CD592C0129C2A5BF009AC14E /* Build configuration list for PBXNativeTarget "serializer" */;
+			buildPhases = (
+				CD592BF929C2A5BF009AC14E /* Headers */,
+				CD592BFA29C2A5BF009AC14E /* Sources */,
+				CD592BFB29C2A5BF009AC14E /* Frameworks */,
+			);
+			buildRules = (
+			);
+			dependencies = (
+			);
+			name = serializer;
+			productName = serializer;
+			productReference = CD592BFD29C2A5BF009AC14E /* libserializer.a */;
+			productType = "com.apple.product-type.library.static";
+		};
+		CD592C1629C3DB32009AC14E /* serializer-test */ = {
+			isa = PBXNativeTarget;
+			buildConfigurationList = CD592C1E29C3DB32009AC14E /* Build configuration list for PBXNativeTarget "serializer-test" */;
+			buildPhases = (
+				CD592C1329C3DB32009AC14E /* Sources */,
+				CD592C1429C3DB32009AC14E /* Frameworks */,
+				CD592C1529C3DB32009AC14E /* Resources */,
+			);
+			buildRules = (
+			);
+			dependencies = (
+				CD592C1D29C3DB32009AC14E /* PBXTargetDependency */,
+			);
+			name = "serializer-test";
+			productName = "serializer-test";
+			productReference = CD592C1729C3DB32009AC14E /* serializer-test.xctest */;
+			productType = "com.apple.product-type.bundle.unit-test";
+		};
+/* End PBXNativeTarget section */
+
+/* Begin PBXProject section */
+		CD592BF529C2A5BF009AC14E /* Project object */ = {
+			isa = PBXProject;
+			attributes = {
+				BuildIndependentTargetsInParallel = 1;
+				LastSwiftUpdateCheck = 1340;
+				LastUpgradeCheck = 1340;
+				TargetAttributes = {
+					CD592BFC29C2A5BF009AC14E = {
+						CreatedOnToolsVersion = 13.4.1;
+					};
+					CD592C1629C3DB32009AC14E = {
+						CreatedOnToolsVersion = 13.4.1;
+					};
+				};
+			};
+			buildConfigurationList = CD592BF829C2A5BF009AC14E /* Build configuration list for PBXProject "serializer" */;
+			compatibilityVersion = "Xcode 13.0";
+			developmentRegion = en;
+			hasScannedForEncodings = 0;
+			knownRegions = (
+				en,
+				Base,
+			);
+			mainGroup = CD592BF429C2A5BF009AC14E;
+			productRefGroup = CD592BFE29C2A5BF009AC14E /* Products */;
+			projectDirPath = "";
+			projectReferences = (
+				{
+					ProductGroup = CD592C2929C3DC76009AC14E /* Products */;
+					ProjectRef = CD592C2829C3DC76009AC14E /* GoogleMock.xcodeproj */;
+				},
+				{
+					ProductGroup = CD592C3829C3DC84009AC14E /* Products */;
+					ProjectRef = CD592C3729C3DC84009AC14E /* string-utils.xcodeproj */;
+				},
+			);
+			projectRoot = "";
+			targets = (
+				CD592BFC29C2A5BF009AC14E /* serializer */,
+				CD592C1629C3DB32009AC14E /* serializer-test */,
+			);
+		};
+/* End PBXProject section */
+
+/* Begin PBXReferenceProxy section */
+		CD592C3029C3DC76009AC14E /* GoogleMock.framework */ = {
+			isa = PBXReferenceProxy;
+			fileType = wrapper.framework;
+			path = GoogleMock.framework;
+			remoteRef = CD592C2F29C3DC76009AC14E /* PBXContainerItemProxy */;
+			sourceTree = BUILT_PRODUCTS_DIR;
+		};
+		CD592C3229C3DC76009AC14E /* gmock.framework */ = {
+			isa = PBXReferenceProxy;
+			fileType = wrapper.framework;
+			path = gmock.framework;
+			remoteRef = CD592C3129C3DC76009AC14E /* PBXContainerItemProxy */;
+			sourceTree = BUILT_PRODUCTS_DIR;
+		};
+		CD592C3429C3DC76009AC14E /* gtest.framework */ = {
+			isa = PBXReferenceProxy;
+			fileType = wrapper.framework;
+			path = gtest.framework;
+			remoteRef = CD592C3329C3DC76009AC14E /* PBXContainerItemProxy */;
+			sourceTree = BUILT_PRODUCTS_DIR;
+		};
+		CD592C3629C3DC76009AC14E /* GoogleMockTests.xctest */ = {
+			isa = PBXReferenceProxy;
+			fileType = wrapper.cfbundle;
+			path = GoogleMockTests.xctest;
+			remoteRef = CD592C3529C3DC76009AC14E /* PBXContainerItemProxy */;
+			sourceTree = BUILT_PRODUCTS_DIR;
+		};
+		CD592C3E29C3DC85009AC14E /* libstring-utils.a */ = {
+			isa = PBXReferenceProxy;
+			fileType = archive.ar;
+			path = "libstring-utils.a";
+			remoteRef = CD592C3D29C3DC85009AC14E /* PBXContainerItemProxy */;
+			sourceTree = BUILT_PRODUCTS_DIR;
+		};
+		CD592C4029C3DC85009AC14E /* string_utils-test.xctest */ = {
+			isa = PBXReferenceProxy;
+			fileType = wrapper.cfbundle;
+			path = "string_utils-test.xctest";
+			remoteRef = CD592C3F29C3DC85009AC14E /* PBXContainerItemProxy */;
+			sourceTree = BUILT_PRODUCTS_DIR;
+		};
+/* End PBXReferenceProxy section */
+
+/* Begin PBXResourcesBuildPhase section */
+		CD592C1529C3DB32009AC14E /* Resources */ = {
+			isa = PBXResourcesBuildPhase;
+			buildActionMask = 2147483647;
+			files = (
+			);
+			runOnlyForDeploymentPostprocessing = 0;
+		};
+/* End PBXResourcesBuildPhase section */
+
+/* Begin PBXSourcesBuildPhase section */
+		CD592BFA29C2A5BF009AC14E /* Sources */ = {
+			isa = PBXSourcesBuildPhase;
+			buildActionMask = 2147483647;
+			files = (
+			);
+			runOnlyForDeploymentPostprocessing = 0;
+		};
+		CD592C1329C3DB32009AC14E /* Sources */ = {
+			isa = PBXSourcesBuildPhase;
+			buildActionMask = 2147483647;
+			files = (
+				CD592C2229C3DB79009AC14E /* jsonizer_test.cxx in Sources */,
+			);
+			runOnlyForDeploymentPostprocessing = 0;
+		};
+/* End PBXSourcesBuildPhase section */
+
+/* Begin PBXTargetDependency section */
+		CD592C1D29C3DB32009AC14E /* PBXTargetDependency */ = {
+			isa = PBXTargetDependency;
+			target = CD592BFC29C2A5BF009AC14E /* serializer */;
+			targetProxy = CD592C1C29C3DB32009AC14E /* PBXContainerItemProxy */;
+		};
+/* End PBXTargetDependency section */
+
+/* Begin XCBuildConfiguration section */
+		CD592BFF29C2A5BF009AC14E /* Debug */ = {
+			isa = XCBuildConfiguration;
+			buildSettings = {
+				ALWAYS_SEARCH_USER_PATHS = NO;
+				CLANG_ANALYZER_NONNULL = YES;
+				CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
+				CLANG_CXX_LANGUAGE_STANDARD = "gnu++17";
+				CLANG_ENABLE_MODULES = YES;
+				CLANG_ENABLE_OBJC_ARC = YES;
+				CLANG_ENABLE_OBJC_WEAK = YES;
+				CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
+				CLANG_WARN_BOOL_CONVERSION = YES;
+				CLANG_WARN_COMMA = YES;
+				CLANG_WARN_CONSTANT_CONVERSION = YES;
+				CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
+				CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
+				CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
+				CLANG_WARN_EMPTY_BODY = YES;
+				CLANG_WARN_ENUM_CONVERSION = YES;
+				CLANG_WARN_INFINITE_RECURSION = YES;
+				CLANG_WARN_INT_CONVERSION = YES;
+				CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
+				CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
+				CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
+				CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
+				CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
+				CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
+				CLANG_WARN_STRICT_PROTOTYPES = YES;
+				CLANG_WARN_SUSPICIOUS_MOVE = YES;
+				CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
+				CLANG_WARN_UNREACHABLE_CODE = YES;
+				CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
+				COPY_PHASE_STRIP = NO;
+				DEBUG_INFORMATION_FORMAT = dwarf;
+				ENABLE_STRICT_OBJC_MSGSEND = YES;
+				ENABLE_TESTABILITY = YES;
+				GCC_C_LANGUAGE_STANDARD = gnu11;
+				GCC_DYNAMIC_NO_PIC = NO;
+				GCC_NO_COMMON_BLOCKS = YES;
+				GCC_OPTIMIZATION_LEVEL = 0;
+				GCC_PREPROCESSOR_DEFINITIONS = (
+					"DEBUG=1",
+					"$(inherited)",
+				);
+				GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
+				GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
+				GCC_WARN_UNDECLARED_SELECTOR = YES;
+				GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
+				GCC_WARN_UNUSED_FUNCTION = YES;
+				GCC_WARN_UNUSED_VARIABLE = YES;
+				MACOSX_DEPLOYMENT_TARGET = 12.0;
+				MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
+				MTL_FAST_MATH = YES;
+				ONLY_ACTIVE_ARCH = YES;
+				SDKROOT = macosx;
+				SYSTEM_HEADER_SEARCH_PATHS = (
+					/opt/local/include,
+					"$(PROJECT_DIR)/include",
+					"$(PROJECT_DIR)/external/string-utils/include",
+					"$(PROJECT_DIR)/external/magic_enum/include",
+				);
+			};
+			name = Debug;
+		};
+		CD592C0029C2A5BF009AC14E /* Release */ = {
+			isa = XCBuildConfiguration;
+			buildSettings = {
+				ALWAYS_SEARCH_USER_PATHS = NO;
+				CLANG_ANALYZER_NONNULL = YES;
+				CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
+				CLANG_CXX_LANGUAGE_STANDARD = "gnu++17";
+				CLANG_ENABLE_MODULES = YES;
+				CLANG_ENABLE_OBJC_ARC = YES;
+				CLANG_ENABLE_OBJC_WEAK = YES;
+				CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
+				CLANG_WARN_BOOL_CONVERSION = YES;
+				CLANG_WARN_COMMA = YES;
+				CLANG_WARN_CONSTANT_CONVERSION = YES;
+				CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
+				CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
+				CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
+				CLANG_WARN_EMPTY_BODY = YES;
+				CLANG_WARN_ENUM_CONVERSION = YES;
+				CLANG_WARN_INFINITE_RECURSION = YES;
+				CLANG_WARN_INT_CONVERSION = YES;
+				CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
+				CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
+				CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
+				CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
+				CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
+				CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
+				CLANG_WARN_STRICT_PROTOTYPES = YES;
+				CLANG_WARN_SUSPICIOUS_MOVE = YES;
+				CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
+				CLANG_WARN_UNREACHABLE_CODE = YES;
+				CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
+				COPY_PHASE_STRIP = NO;
+				DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
+				ENABLE_NS_ASSERTIONS = NO;
+				ENABLE_STRICT_OBJC_MSGSEND = YES;
+				GCC_C_LANGUAGE_STANDARD = gnu11;
+				GCC_NO_COMMON_BLOCKS = YES;
+				GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
+				GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
+				GCC_WARN_UNDECLARED_SELECTOR = YES;
+				GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
+				GCC_WARN_UNUSED_FUNCTION = YES;
+				GCC_WARN_UNUSED_VARIABLE = YES;
+				MACOSX_DEPLOYMENT_TARGET = 12.0;
+				MTL_ENABLE_DEBUG_INFO = NO;
+				MTL_FAST_MATH = YES;
+				SDKROOT = macosx;
+				SYSTEM_HEADER_SEARCH_PATHS = (
+					/opt/local/include,
+					"$(PROJECT_DIR)/include",
+					"$(PROJECT_DIR)/external/string-utils/include",
+					"$(PROJECT_DIR)/external/magic_enum/include",
+				);
+			};
+			name = Release;
+		};
+		CD592C0229C2A5BF009AC14E /* Debug */ = {
+			isa = XCBuildConfiguration;
+			buildSettings = {
+				CODE_SIGN_STYLE = Automatic;
+				EXECUTABLE_PREFIX = lib;
+				PRODUCT_NAME = "$(TARGET_NAME)";
+				SKIP_INSTALL = YES;
+			};
+			name = Debug;
+		};
+		CD592C0329C2A5BF009AC14E /* Release */ = {
+			isa = XCBuildConfiguration;
+			buildSettings = {
+				CODE_SIGN_STYLE = Automatic;
+				EXECUTABLE_PREFIX = lib;
+				PRODUCT_NAME = "$(TARGET_NAME)";
+				SKIP_INSTALL = YES;
+			};
+			name = Release;
+		};
+		CD592C1F29C3DB32009AC14E /* Debug */ = {
+			isa = XCBuildConfiguration;
+			buildSettings = {
+				CODE_SIGN_STYLE = Automatic;
+				CURRENT_PROJECT_VERSION = 1;
+				GENERATE_INFOPLIST_FILE = YES;
+				LIBRARY_SEARCH_PATHS = (
+					"$(inherited)",
+					/opt/local/lib,
+				);
+				MARKETING_VERSION = 1.0;
+				PRODUCT_BUNDLE_IDENTIFIER = "leumasjaffe.serializer-test";
+				PRODUCT_NAME = "$(TARGET_NAME)";
+				SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
+				SWIFT_EMIT_LOC_STRINGS = NO;
+				SWIFT_OPTIMIZATION_LEVEL = "-Onone";
+				SWIFT_VERSION = 5.0;
+			};
+			name = Debug;
+		};
+		CD592C2029C3DB32009AC14E /* Release */ = {
+			isa = XCBuildConfiguration;
+			buildSettings = {
+				CODE_SIGN_STYLE = Automatic;
+				CURRENT_PROJECT_VERSION = 1;
+				GENERATE_INFOPLIST_FILE = YES;
+				LIBRARY_SEARCH_PATHS = (
+					"$(inherited)",
+					/opt/local/lib,
+				);
+				MARKETING_VERSION = 1.0;
+				PRODUCT_BUNDLE_IDENTIFIER = "leumasjaffe.serializer-test";
+				PRODUCT_NAME = "$(TARGET_NAME)";
+				SWIFT_COMPILATION_MODE = wholemodule;
+				SWIFT_EMIT_LOC_STRINGS = NO;
+				SWIFT_OPTIMIZATION_LEVEL = "-O";
+				SWIFT_VERSION = 5.0;
+			};
+			name = Release;
+		};
+/* End XCBuildConfiguration section */
+
+/* Begin XCConfigurationList section */
+		CD592BF829C2A5BF009AC14E /* Build configuration list for PBXProject "serializer" */ = {
+			isa = XCConfigurationList;
+			buildConfigurations = (
+				CD592BFF29C2A5BF009AC14E /* Debug */,
+				CD592C0029C2A5BF009AC14E /* Release */,
+			);
+			defaultConfigurationIsVisible = 0;
+			defaultConfigurationName = Release;
+		};
+		CD592C0129C2A5BF009AC14E /* Build configuration list for PBXNativeTarget "serializer" */ = {
+			isa = XCConfigurationList;
+			buildConfigurations = (
+				CD592C0229C2A5BF009AC14E /* Debug */,
+				CD592C0329C2A5BF009AC14E /* Release */,
+			);
+			defaultConfigurationIsVisible = 0;
+			defaultConfigurationName = Release;
+		};
+		CD592C1E29C3DB32009AC14E /* Build configuration list for PBXNativeTarget "serializer-test" */ = {
+			isa = XCConfigurationList;
+			buildConfigurations = (
+				CD592C1F29C3DB32009AC14E /* Debug */,
+				CD592C2029C3DB32009AC14E /* Release */,
+			);
+			defaultConfigurationIsVisible = 0;
+			defaultConfigurationName = Release;
+		};
+/* End XCConfigurationList section */
+	};
+	rootObject = CD592BF529C2A5BF009AC14E /* Project object */;
+}

+ 78 - 0
serializer.xcodeproj/xcshareddata/xcschemes/serializer.xcscheme

@@ -0,0 +1,78 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Scheme
+   LastUpgradeVersion = "1340"
+   version = "1.3">
+   <BuildAction
+      parallelizeBuildables = "YES"
+      buildImplicitDependencies = "YES">
+      <BuildActionEntries>
+         <BuildActionEntry
+            buildForTesting = "YES"
+            buildForRunning = "YES"
+            buildForProfiling = "YES"
+            buildForArchiving = "YES"
+            buildForAnalyzing = "YES">
+            <BuildableReference
+               BuildableIdentifier = "primary"
+               BlueprintIdentifier = "CD592BFC29C2A5BF009AC14E"
+               BuildableName = "libserializer.a"
+               BlueprintName = "serializer"
+               ReferencedContainer = "container:serializer.xcodeproj">
+            </BuildableReference>
+         </BuildActionEntry>
+      </BuildActionEntries>
+   </BuildAction>
+   <TestAction
+      buildConfiguration = "Debug"
+      selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
+      selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
+      shouldUseLaunchSchemeArgsEnv = "YES"
+      codeCoverageEnabled = "YES">
+      <Testables>
+         <TestableReference
+            skipped = "NO">
+            <BuildableReference
+               BuildableIdentifier = "primary"
+               BlueprintIdentifier = "CD592C1629C3DB32009AC14E"
+               BuildableName = "serializer-test.xctest"
+               BlueprintName = "serializer-test"
+               ReferencedContainer = "container:serializer.xcodeproj">
+            </BuildableReference>
+         </TestableReference>
+      </Testables>
+   </TestAction>
+   <LaunchAction
+      buildConfiguration = "Debug"
+      selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
+      selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
+      launchStyle = "0"
+      useCustomWorkingDirectory = "NO"
+      ignoresPersistentStateOnLaunch = "NO"
+      debugDocumentVersioning = "YES"
+      debugServiceExtension = "internal"
+      allowLocationSimulation = "YES">
+   </LaunchAction>
+   <ProfileAction
+      buildConfiguration = "Release"
+      shouldUseLaunchSchemeArgsEnv = "YES"
+      savedToolIdentifier = ""
+      useCustomWorkingDirectory = "NO"
+      debugDocumentVersioning = "YES">
+      <MacroExpansion>
+         <BuildableReference
+            BuildableIdentifier = "primary"
+            BlueprintIdentifier = "CD592BFC29C2A5BF009AC14E"
+            BuildableName = "libserializer.a"
+            BlueprintName = "serializer"
+            ReferencedContainer = "container:serializer.xcodeproj">
+         </BuildableReference>
+      </MacroExpansion>
+   </ProfileAction>
+   <AnalyzeAction
+      buildConfiguration = "Debug">
+   </AnalyzeAction>
+   <ArchiveAction
+      buildConfiguration = "Release"
+      revealArchiveInOrganizer = "YES">
+   </ArchiveAction>
+</Scheme>

+ 11 - 0
test/jsonizer_test.cxx

@@ -0,0 +1,11 @@
+//
+//  jsonizer_test.cxx
+//  serializer-test
+//
+//  Created by Sam Jaffe on 3/16/23.
+//
+
+#include "xcode_gtest_helper.h"
+
+#include <serializer/jsonizer.tpp>
+

+ 39 - 0
test/xcode_gtest_helper.h

@@ -0,0 +1,39 @@
+//
+//  xcode_gtest_helper.h
+//  tax-calculator-test
+//
+//  Created by Sam Jaffe on 11/25/20.
+//  Copyright © 2020 Sam Jaffe. All rights reserved.
+//
+
+#pragma once
+
+#if defined(__APPLE__)
+
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wquoted-include-in-framework-header"
+#pragma clang diagnostic ignored "-Wcomma"
+
+#include <gmock/gmock.h>
+#include <gtest/gtest.h>
+
+#pragma clang diagnostic pop
+
+#if defined(TARGET_OS_OSX)
+// This is a hack to allow XCode to properly display failures when running
+// unit tests.
+#undef EXPECT_THAT
+#define EXPECT_THAT ASSERT_THAT
+#undef EXPECT_THROW
+#define EXPECT_THROW ASSERT_THROW
+#undef EXPECT_ANY_THROW
+#define EXPECT_ANY_THROW ASSERT_ANY_THROW
+#undef EXPECT_NO_THROW
+#define EXPECT_NO_THROW ASSERT_NO_THROW
+#undef EXPECT_TRUE
+#define EXPECT_TRUE ASSERT_TRUE
+#undef EXPECT_FALSE
+#define EXPECT_FALSE ASSERT_FALSE
+
+#endif
+#endif