/* * WiVRn VR streaming * Copyright (C) 2022 Guillaume Meunier * Copyright (C) 2022 Patrick Nicolas * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "wivrn_serialization.h" using namespace wivrn; namespace { template constexpr uint64_t hash(T s) { return details::hash_context{}.feed(s); } static_assert(hash("test") == 0xf9e6e6ef197c2b25); static_assert(hash(1234) == 0x1fabbdf10314a21d); static_assert(hash(-1234) == 0x77fa1c9653db5a84); static_assert(hash(0) == 0xaf63ad4c86019caf); static_assert(serialization_type_hash(0) == hash("uint8")); static_assert(serialization_type_hash(0) == hash("int32")); static_assert(serialization_type_hash(0) == hash("float32")); static_assert(serialization_type_hash(0) == hash("float64")); static_assert(serialization_type_hash(0) == hash("duration")); static_assert(serialization_type_hash>(0) == hash("optional")); static_assert(serialization_type_hash>(0) == hash("vector")); static_assert(serialization_type_hash>(0) == hash("array")); static_assert(serialization_type_hash(0) == hash("string")); static_assert(serialization_type_hash>(0) == hash("variant")); struct test { int x; float y; }; static_assert(serialization_type_hash(0) == hash("structure{int32,float32}")); enum test_enum : uint32_t { foo, bar, foobar = 42 }; static_assert(serialization_type_hash(0) == hash("enum32{foo=0,bar=1,foobar=42}")); } // namespace