Bladeren bron

小修改

akemimadoka 7 jaren geleden
bovenliggende
commit
ee24807769
5 gewijzigde bestanden met toevoegingen van 14 en 5 verwijderingen
  1. 1 1
      Extern/NatsuLib
  2. 2 2
      YumeBot.Test/CryptographyTest.cpp
  3. 8 0
      YumeBot/Jce.cpp
  4. 1 1
      YumeBot/TlvCodeDef.h
  5. 2 1
      YumeBot/YumeBot.cpp

+ 1 - 1
Extern/NatsuLib

@@ -1 +1 @@
-Subproject commit ccaad4e75ef4ca0e25e8f2d11db663a8a178f273
+Subproject commit 3870862a4a3bb06b627aa1395983435fbd8952fa

+ 2 - 2
YumeBot.Test/CryptographyTest.cpp

@@ -25,7 +25,7 @@ TEST_CASE("Cryptography", "[Utility][Cryptography]")
 		char decryptResult[std::size(result)]{};
 		const auto decryptResultSize = Decrypt(Utility::ToByteSpan(result), Utility::ToByteSpan(decryptResult), formattedKey);
 
-		REQUIRE(resultSize == Cryptography::Tea::CalculateOutputSize(std::size(text)));
+		REQUIRE(resultSize == CalculateOutputSize(std::size(text)));
 		REQUIRE(decryptResultSize == std::size(text));
 		REQUIRE(std::memcmp(decryptResult, text, std::size(text)) == 0);
 	}
@@ -37,7 +37,7 @@ TEST_CASE("Cryptography", "[Utility][Cryptography]")
 		constexpr const char test[] = "test";
 
 		std::byte result[16];
-		Calculate(Utility::ToByteSpan(test).subspan(0, 4), result);
+		Calculate(Utility::ToByteSpan(test).subspan(0, std::size(test) - 1), result);
 
 		constexpr const nByte expectedResult[] = "\x09\x8f\x6b\xcd\x46\x21\xd3\x73\xca\xde\x4e\x83\x26\x27\xb4\xf6";
 		REQUIRE(std::memcmp(result, expectedResult, std::size(result)) == 0);

+ 8 - 0
YumeBot/Jce.cpp

@@ -11,6 +11,10 @@ JceStruct::~JceStruct()
 JceInputStream::JceInputStream(natRefPointer<natBinaryReader> reader)
 	: m_Reader{ std::move(reader) }
 {
+	if (m_Reader->GetEndianness() != Environment::Endianness::LittleEndian)
+	{
+		nat_Throw(JceDecodeException, u8"reader should use little endian."_nv);
+	}
 }
 
 JceInputStream::~JceInputStream()
@@ -20,6 +24,10 @@ JceInputStream::~JceInputStream()
 JceOutputStream::JceOutputStream(natRefPointer<natBinaryWriter> writer)
 	: m_Writer{ std::move(writer) }
 {
+	if (m_Writer->GetEndianness() != Environment::Endianness::LittleEndian)
+	{
+		nat_Throw(JceDecodeException, u8"writer should use little endian."_nv);
+	}
 }
 
 JceOutputStream::~JceOutputStream()

+ 1 - 1
YumeBot/TlvCodeDef.h

@@ -77,7 +77,7 @@
 TLV_CODE(TlvTest, 0)
 	INT(TestInt, 0)
 	FLOAT(TestFloat, 1, IS_OPTIONAL(1.0f))
-	MAP(TestMap, 2, TEMPLATE_ARGUMENT(int, float))
+	MAP(TestMap, 2, TEMPLATE_ARGUMENT(std::int32_t, float))
 END_TLV_CODE(TlvTest)
 
 #undef SIMPLE_LIST

+ 2 - 1
YumeBot/YumeBot.cpp

@@ -3,7 +3,8 @@
 using namespace NatsuLib;
 using namespace YumeBot;
 
-Bot::Bot(): m_Socket(m_Service)
+Bot::Bot()
+	: m_Socket(m_Service)
 {
 }