Skip to content

Commit 568f3e7

Browse files
committed
test: add empty string and unicode edge cases to ValueTest
1 parent a88681a commit 568f3e7

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

api/all/src/test/java/io/opentelemetry/api/logs/ValueTest.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,5 +211,17 @@ void valueByteAsString() {
211211
String base64Encoded = Value.of(str.getBytes(StandardCharsets.UTF_8)).asString();
212212
byte[] decodedBytes = Base64.getDecoder().decode(base64Encoded);
213213
assertThat(new String(decodedBytes, StandardCharsets.UTF_8)).isEqualTo(str);
214+
215+
// Test empty string
216+
String emptyStr = "";
217+
String emptyBase64 = Value.of(emptyStr.getBytes(StandardCharsets.UTF_8)).asString();
218+
byte[] decodedEmpty = Base64.getDecoder().decode(emptyBase64);
219+
assertThat(new String(decodedEmpty, StandardCharsets.UTF_8)).isEqualTo(emptyStr);
220+
221+
// Test string with special characters
222+
String specialStr = "hello \n \t 🌍 world!";
223+
String specialBase64 = Value.of(specialStr.getBytes(StandardCharsets.UTF_8)).asString();
224+
byte[] decodedSpecial = Base64.getDecoder().decode(specialBase64);
225+
assertThat(new String(decodedSpecial, StandardCharsets.UTF_8)).isEqualTo(specialStr);
214226
}
215227
}

0 commit comments

Comments
 (0)