diff options
author | wolfbeast <mcwerewolf@gmail.com> | 2018-03-13 12:15:45 +0100 |
---|---|---|
committer | wolfbeast <mcwerewolf@gmail.com> | 2018-03-13 12:15:45 +0100 |
commit | 7c68c5a22cfe8f83322836a1a6a76a8ae0415ec1 (patch) | |
tree | ee9e0946bca9e3eb2f610b52a0c6b1167b11f0ff /xpcom/rust/nsstring/gtest/Test.cpp | |
parent | a1f143420203395d9a7f347bb232ca86daa40f2b (diff) | |
download | UXP-7c68c5a22cfe8f83322836a1a6a76a8ae0415ec1.tar UXP-7c68c5a22cfe8f83322836a1a6a76a8ae0415ec1.tar.gz UXP-7c68c5a22cfe8f83322836a1a6a76a8ae0415ec1.tar.lz UXP-7c68c5a22cfe8f83322836a1a6a76a8ae0415ec1.tar.xz UXP-7c68c5a22cfe8f83322836a1a6a76a8ae0415ec1.zip |
Remove cargo nsstring component
Part 3 for #58
Diffstat (limited to 'xpcom/rust/nsstring/gtest/Test.cpp')
-rw-r--r-- | xpcom/rust/nsstring/gtest/Test.cpp | 131 |
1 files changed, 0 insertions, 131 deletions
diff --git a/xpcom/rust/nsstring/gtest/Test.cpp b/xpcom/rust/nsstring/gtest/Test.cpp deleted file mode 100644 index 93d2ee1d7..000000000 --- a/xpcom/rust/nsstring/gtest/Test.cpp +++ /dev/null @@ -1,131 +0,0 @@ -#include "gtest/gtest.h" -#include <stdint.h> -#include "nsString.h" - -extern "C" { - // This function is called by the rust code in test.rs if a non-fatal test - // failure occurs. - void GTest_ExpectFailure(const char* aMessage) { - EXPECT_STREQ(aMessage, ""); - } -} - -#define SIZE_ALIGN_CHECK(Clazz) \ - extern "C" void Rust_Test_ReprSizeAlign_##Clazz(size_t* size, size_t* align); \ - TEST(RustNsString, ReprSizeAlign_##Clazz) { \ - size_t size, align; \ - Rust_Test_ReprSizeAlign_##Clazz(&size, &align); \ - EXPECT_EQ(size, sizeof(Clazz)); \ - EXPECT_EQ(align, alignof(Clazz)); \ - } - -SIZE_ALIGN_CHECK(nsString) -SIZE_ALIGN_CHECK(nsCString) -SIZE_ALIGN_CHECK(nsFixedString) -SIZE_ALIGN_CHECK(nsFixedCString) - -#define MEMBER_CHECK(Clazz, Member) \ - extern "C" void Rust_Test_Member_##Clazz##_##Member(size_t* size, \ - size_t* align, \ - size_t* offset); \ - TEST(RustNsString, ReprMember_##Clazz##_##Member) { \ - class Hack : public Clazz { \ - public: \ - static void RunTest() { \ - size_t size, align, offset; \ - Rust_Test_Member_##Clazz##_##Member(&size, &align, &offset); \ - EXPECT_EQ(size, sizeof(mozilla::DeclVal<Hack>().Member)); \ - EXPECT_EQ(size, alignof(decltype(mozilla::DeclVal<Hack>().Member))); \ - EXPECT_EQ(offset, offsetof(Hack, Member)); \ - } \ - }; \ - static_assert(sizeof(Clazz) == sizeof(Hack), "Hack matches class"); \ - Hack::RunTest(); \ - } - -MEMBER_CHECK(nsString, mData) -MEMBER_CHECK(nsString, mLength) -MEMBER_CHECK(nsString, mFlags) -MEMBER_CHECK(nsCString, mData) -MEMBER_CHECK(nsCString, mLength) -MEMBER_CHECK(nsCString, mFlags) -MEMBER_CHECK(nsFixedString, mFixedCapacity) -MEMBER_CHECK(nsFixedString, mFixedBuf) -MEMBER_CHECK(nsFixedCString, mFixedCapacity) -MEMBER_CHECK(nsFixedCString, mFixedBuf) - -extern "C" void Rust_Test_NsStringFlags(uint32_t* f_none, - uint32_t* f_terminated, - uint32_t* f_voided, - uint32_t* f_shared, - uint32_t* f_owned, - uint32_t* f_fixed, - uint32_t* f_literal, - uint32_t* f_class_fixed); -TEST(RustNsString, NsStringFlags) { - uint32_t f_none, f_terminated, f_voided, f_shared, f_owned, f_fixed, f_literal, f_class_fixed; - Rust_Test_NsStringFlags(&f_none, &f_terminated, - &f_voided, &f_shared, - &f_owned, &f_fixed, - &f_literal, &f_class_fixed); - EXPECT_EQ(f_none, nsAString::F_NONE); - EXPECT_EQ(f_none, nsACString::F_NONE); - EXPECT_EQ(f_terminated, nsAString::F_TERMINATED); - EXPECT_EQ(f_terminated, nsACString::F_TERMINATED); - EXPECT_EQ(f_voided, nsAString::F_VOIDED); - EXPECT_EQ(f_voided, nsACString::F_VOIDED); - EXPECT_EQ(f_shared, nsAString::F_SHARED); - EXPECT_EQ(f_shared, nsACString::F_SHARED); - EXPECT_EQ(f_owned, nsAString::F_OWNED); - EXPECT_EQ(f_owned, nsACString::F_OWNED); - EXPECT_EQ(f_fixed, nsAString::F_FIXED); - EXPECT_EQ(f_fixed, nsACString::F_FIXED); - EXPECT_EQ(f_literal, nsAString::F_LITERAL); - EXPECT_EQ(f_literal, nsACString::F_LITERAL); - EXPECT_EQ(f_class_fixed, nsAString::F_CLASS_FIXED); - EXPECT_EQ(f_class_fixed, nsACString::F_CLASS_FIXED); -} - -extern "C" void Rust_StringFromCpp(const nsACString* aCStr, const nsAString* aStr); -TEST(RustNsString, StringFromCpp) { - nsAutoCString foo; - foo.AssignASCII("Hello, World!"); - - nsAutoString bar; - bar.AssignASCII("Hello, World!"); - - Rust_StringFromCpp(&foo, &bar); -} - -extern "C" void Rust_AssignFromRust(nsACString* aCStr, nsAString* aStr); -TEST(RustNsString, AssignFromRust) { - nsAutoCString cs; - nsAutoString s; - Rust_AssignFromRust(&cs, &s); - EXPECT_TRUE(cs.EqualsASCII("Hello, World!")); - EXPECT_TRUE(s.EqualsASCII("Hello, World!")); -} - -extern "C" { - void Cpp_AssignFromCpp(nsACString* aCStr, nsAString* aStr) { - aCStr->AssignASCII("Hello, World!"); - aStr->AssignASCII("Hello, World!"); - } -} -extern "C" void Rust_AssignFromCpp(); -TEST(RustNsString, AssignFromCpp) { - Rust_AssignFromCpp(); -} -extern "C" void Rust_FixedAssignFromCpp(); -TEST(RustNsString, FixedAssignFromCpp) { - Rust_FixedAssignFromCpp(); -} -extern "C" void Rust_AutoAssignFromCpp(); -TEST(RustNsString, AutoAssignFromCpp) { - Rust_AutoAssignFromCpp(); -} - -extern "C" void Rust_StringWrite(); -TEST(RustNsString, StringWrite) { - Rust_StringWrite(); -} |