public void Compress(string input, string expected) { var solution = new StringCompressor(); var actual = solution.Compress(input); Assert.Equal(expected, actual); }
public void Share() { string buf = StringCompressor.Compress(SaveSharing()); print(buf); print(StringCompressor.Decompress(buf)); StartCoroutine(ShareAndRate.ShareAndroidText(buf)); }
public void Decompress_WhenGivenCompressedString_ReturnsOriginalUncompressedString() { // Act var compressedJson = _stringCompressor.Compress(TestJson); var decompressedJson = _stringCompressor.Decompress(compressedJson); // Assert decompressedJson.Should().Be(TestJson); }
internal Byte[] EncodeImpl(Log log) { String logObjectStr = null; if (log.LogObject is String str) { if (log.IsRawString) { // String을 그대로 저장하면 Athena에서 다른 JSON로그와 문제가 되므로 변환한다. log.LogObject = new StringLogObject { raw = str }; // { "raw" : "로그문자열" } } else { // String이지만 JSON으로 변환된 상태이므로 그대로 전송한다. logObjectStr = str; } } logObjectStr = logObjectStr ?? _jsonSerializer.Serialize(log.LogObject); String compressedLog = null; String plainLog = null; if (_compressLogThresholdByte < logObjectStr.Length) { compressedLog = StringCompressor.Compress(logObjectStr); } else { plainLog = logObjectStr; } var putString = new StringBuilder(_jsonSerializer.Serialize(new PutData { ID = _id, InstanceID = _instanceID, Sequence = log.Sequence, TimeStamp = log.TimeStamp, TimeStampNS = log.TimeStampNS, LogType = log.LogType, CompressedLog = compressedLog, Log = plainLog })); putString.Append(Const.LOG_DELIMITER); Byte[] encodedLog = Encoding.UTF8.GetBytes(putString.ToString()); return(encodedLog); }
public void 압축_테스트() { const String ORIGIN_TEXT = "Test text..... test test test !!!!!!!!!!! 1234567890"; String compressed = StringCompressor.Compress(ORIGIN_TEXT); String decompressed = StringCompressor.Decompress(compressed); Assert.IsTrue(decompressed == ORIGIN_TEXT); Assert.IsTrue(StringCompressor.Compress(null) == String.Empty); Assert.IsTrue(StringCompressor.Decompress(null) == String.Empty); }
public static string SerializeDataStructure(ISerializable serializableDataStructure) { MemoryStream ms = new MemoryStream(); MemoryStream ms2 = new MemoryStream(); StringCompressor sc = new StringCompressor(); BinaryFormatter formatter = new BinaryFormatter(); try { formatter.Serialize(ms, serializableDataStructure); sc.Compress(ms, ms2); return(Convert.ToBase64String(ms2.ToArray())); } catch { return(null); } }
public void TestMethod1() { StringCompressor sc = new StringCompressor(); Assert.AreEqual <string>("2a1b5c3b", sc.Compress("aabcccccbbb")); Assert.AreEqual <string>("aa", sc.Compress("aa")); Assert.AreEqual <string>("", sc.Compress("")); Assert.AreEqual <string>("", sc.Compress(null)); Assert.AreEqual <string>("abccdefg", sc.Compress("abccdefg")); Assert.AreEqual <string>("3a3b1g1c3t3s2f", sc.Compress("aaabbbgctttsssff")); }