From fcddb4b28f0c9981f0617d4f9ae7e8acb58c0b82 Mon Sep 17 00:00:00 2001 From: Eric Sink Date: Tue, 9 Feb 2021 12:51:00 -0600 Subject: [PATCH] rename to utf8z.GetZeroTerminatedUTF8Bytes() and add a simple test case for it. #399 --- Directory.Build.props | 6 +++--- src/SQLitePCLRaw.core/utf8z.cs | 2 +- src/common/tests_xunit.cs | 9 +++++++++ 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/Directory.Build.props b/Directory.Build.props index 24737ff3..ddfc3065 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -4,9 +4,9 @@ Copyright 2014-2021 SourceGear, LLC SourceGear Eric Sink - 2.0.5-pre20210120090000 - 2.0.5.1115 - 2.0.5.1115 + 2.0.5-pre20210209124043 + 2.0.5.1135 + 2.0.5.1135 SQLitePCLRaw is a Portable Class Library (PCL) for low-level (raw) access to SQLite 7.3 false diff --git a/src/SQLitePCLRaw.core/utf8z.cs b/src/SQLitePCLRaw.core/utf8z.cs index 42150eca..9493690a 100644 --- a/src/SQLitePCLRaw.core/utf8z.cs +++ b/src/SQLitePCLRaw.core/utf8z.cs @@ -183,7 +183,7 @@ public string utf8_to_string() /// int)"/>. Note that for the length provided should not include the /// trailing \0 terminator. /// - public static byte[] GetNullTerminatedUTF8Bytes(string value) + public static byte[] GetZeroTerminatedUTF8Bytes(string value) { return util.to_utf8_with_z(value); } diff --git a/src/common/tests_xunit.cs b/src/common/tests_xunit.cs index 9fa1cf4d..fe28123c 100644 --- a/src/common/tests_xunit.cs +++ b/src/common/tests_xunit.cs @@ -55,6 +55,15 @@ public static byte[] to_utf8(string s) [Collection("Init")] public class test_cases { + [Fact] + public void test_GetZeroTerminatedUTF8Bytes() + { + const string s = "hello"; + var ba = utf8z.GetZeroTerminatedUTF8Bytes("hello"); + Assert.Equal(s.Length + 1, ba.Length); + Assert.Equal(0, ba[s.Length]); + } + [Fact] public void test_call_sqlite3_enable_load_extension() {