diff options
| author | Andrey Lihatskiy <118752495+marchcat@users.noreply.github.com> | 2026-08-13 20:18:46 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-08-13 20:18:46 +0300 |
| commit | 039c1b4b027a5f34449a934d9aea0cea8a2c7659 (patch) | |
| tree | f27a36ca21ab04d7e3ddb0c65ea39ee063252611 /indra/llcommon/tests/llsdserialize_test.cpp | |
| parent | c8730531ee1a030c4e71f2b7ddb7d3394c9af7b7 (diff) | |
| parent | f376c52ee2a22b3b58263d86566394e80626fc1a (diff) | |
Merge pull request #6133 from secondlife/marchcat/lua-linux-develop
geenz/linux-to-develop to lua_editor
Diffstat (limited to 'indra/llcommon/tests/llsdserialize_test.cpp')
| -rw-r--r-- | indra/llcommon/tests/llsdserialize_test.cpp | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/indra/llcommon/tests/llsdserialize_test.cpp b/indra/llcommon/tests/llsdserialize_test.cpp index a7abfda099..71096523a9 100644 --- a/indra/llcommon/tests/llsdserialize_test.cpp +++ b/indra/llcommon/tests/llsdserialize_test.cpp @@ -243,6 +243,58 @@ namespace tut xml_test("binary", expected); } + template<> template<> + void sd_xml_object::test<7>() + { + // Test that stream state (precision and exceptions) is correctly restored after format() + { + std::ostringstream ostr; + + // Set custom precision + ostr.precision(10); + + // Set some exception bits + ostr.exceptions(std::ios_base::badbit); + std::ios_base::iostate original_exceptions = ostr.exceptions(); + + // Format some LLSD data + mSD = 3.141592653589793; + S32 result = mFormatter->format(mSD, ostr); + + // Verify formatting succeeded + ensure("format should succeed", result >= 0); + + // Verify precision was restored + ensure_equals("precision should be restored", + ostr.precision(), 10); + + // Verify exceptions were restored + ensure_equals("exception bits should be restored", + ostr.exceptions(), original_exceptions); + } + + // Test with no bits set + { + std::ostringstream ostr; + ostr.precision(5); + std::ios_base::iostate original_exceptions = ostr.exceptions(); // 0 + + mSD = "test"; + S32 result = mFormatter->format(mSD, ostr); + + // Verify formatting succeeded + ensure("format should succeed", result >= 0); + + // Verify exceptions were removed + ensure_equals("exception bits should remain unchanged", + ostr.exceptions(), original_exceptions); + + // Verify precision was still restored even on failure + ensure_equals("precision should be restored even on stream failure", + ostr.precision(), (std::streamsize)5); + } + } + class TestLLSDSerializeData { public: |
