var kim = use("kim");
var blob = use('blob')

// Test basic ASCII
var test1 = "Hello, World!";
var encoded1 = kim.encode(test1);
var decoded1 = kim.decode(encoded1);
log.console("ASCII test:", test1 == decoded1 ? "PASS" : "FAIL");
if (test1 != decoded1) {
  log.console("  Expected:", test1);
  log.console("  Got:", decoded1);
}

// Test Unicode characters
var test2 = "Hello, 世界! 🌍 Привет мир";
var encoded2 = kim.encode(test2);
var decoded2 = kim.decode(encoded2);
log.console("Unicode test:", test2 == decoded2 ? "PASS" : "FAIL");
if (test2 != decoded2) {
  log.console("  Expected:", test2);
  log.console("  Got:", decoded2);
}

// Test empty string
var test3 = "";
var encoded3 = kim.encode(test3);
log.console(typeof encoded3)
log.console(encoded3 instanceof blob)
var decoded3 = kim.decode(encoded3);
log.console("Empty string test:", test3 == decoded3 ? "PASS" : "FAIL");

// Test various Unicode ranges
var test4 = "αβγδε АБВГД 你好 😀😎🎉 ∑∏∫";
var encoded4 = kim.encode(test4);
var decoded4 = kim.decode(encoded4);
log.console("Mixed Unicode test:", test4 == decoded4 ? "PASS" : "FAIL");
if (test4 != decoded4) {
  log.console("  Expected:", test4);
  log.console("  Got:", decoded4);
}

// Test efficiency - KIM should be smaller for high codepoints
var highCodepoints = "🌍🌎🌏🗺️🧭";
var encodedHigh = kim.encode(highCodepoints);
var utf8Bytes = new Blob([highCodepoints]).size;
log.console("High codepoint efficiency:");
log.console("  UTF-8 bytes:", utf8Bytes);
log.console("  KIM bytes:", encodedHigh.byteLength);
log.console("  Savings:", utf8Bytes - encodedHigh.byteLength, "bytes");

log.console("\nAll tests completed!");