|
|
@@ -103,10 +103,11 @@ namespace TensorFlowNET.UnitTest |
|
|
|
public void StringEncode() |
|
|
|
{ |
|
|
|
string str = "Hello, TensorFlow.NET!"; |
|
|
|
var handle = Marshal.StringToHGlobalAnsi(str); |
|
|
|
ulong dst_len = c_api.TF_StringEncodedSize((ulong)str.Length); |
|
|
|
Assert.AreEqual(dst_len, (ulong)23); |
|
|
|
IntPtr dst = Marshal.AllocHGlobal((int)dst_len); |
|
|
|
ulong encoded_len = c_api.TF_StringEncode(str, (ulong)str.Length, dst, dst_len, status); |
|
|
|
ulong encoded_len = c_api.TF_StringEncode(handle, (ulong)str.Length, dst, dst_len, status); |
|
|
|
Assert.AreEqual((ulong)23, encoded_len); |
|
|
|
Assert.AreEqual(status.Code, TF_Code.TF_OK); |
|
|
|
string encoded_str = Marshal.PtrToStringUTF8(dst + sizeof(byte)); |
|
|
|