react-native-update 10.53.1 → 10.55.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (106) hide show
  1. package/README-CN.md +59 -31
  2. package/README.md +62 -32
  3. package/android/jni/HDiffPatch/.travis.yml +33 -0
  4. package/android/jni/HDiffPatch/builds/xcode/bestParams.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
  5. package/android/jni/HDiffPatch/builds/xcode/hdiffz.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
  6. package/android/jni/HDiffPatch/builds/xcode/hdiffz.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
  7. package/android/jni/HDiffPatch/builds/xcode/hpatchz.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
  8. package/android/jni/HDiffPatch/builds/xcode/lz4.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
  9. package/android/jni/HDiffPatch/builds/xcode/lzma.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
  10. package/android/jni/HDiffPatch/builds/xcode/testHashClash.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
  11. package/android/jni/HDiffPatch/builds/xcode/testHashClash.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
  12. package/android/jni/HDiffPatch/builds/xcode/unitTest.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
  13. package/android/jni/HDiffPatch/builds/xcode/zstd.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
  14. package/android/jni/lzma/DOC/7zC.txt +187 -0
  15. package/android/jni/lzma/DOC/7zFormat.txt +469 -0
  16. package/android/jni/lzma/DOC/Methods.txt +173 -0
  17. package/android/jni/lzma/DOC/installer.txt +166 -0
  18. package/android/jni/lzma/DOC/lzma-history.txt +446 -0
  19. package/android/jni/lzma/DOC/lzma-sdk.txt +357 -0
  20. package/android/jni/lzma/DOC/lzma-specification.txt +1176 -0
  21. package/android/jni/lzma/DOC/lzma.txt +328 -0
  22. package/android/jni/lzma/bin/7zS2.sfx +0 -0
  23. package/android/jni/lzma/bin/7zS2con.sfx +0 -0
  24. package/android/jni/lzma/bin/7zSD.sfx +0 -0
  25. package/android/jni/lzma/bin/7zdec.exe +0 -0
  26. package/android/jni/lzma/bin/7zr.exe +0 -0
  27. package/android/jni/lzma/bin/installer/config.txt +5 -0
  28. package/android/jni/lzma/bin/installer/cr.bat +5 -0
  29. package/android/jni/lzma/bin/lzma.exe +0 -0
  30. package/android/jni/lzma/bin/x64/7zr.exe +0 -0
  31. package/android/lib/arm64-v8a/librnupdate.so +0 -0
  32. package/android/lib/armeabi-v7a/librnupdate.so +0 -0
  33. package/android/lib/x86/librnupdate.so +0 -0
  34. package/android/lib/x86_64/librnupdate.so +0 -0
  35. package/android/src/main/java/cn/reactnative/modules/update/ArchiveLimits.java +44 -0
  36. package/android/src/main/java/cn/reactnative/modules/update/DownloadTask.java +124 -40
  37. package/android/src/main/java/cn/reactnative/modules/update/InstallRecord.java +125 -0
  38. package/android/src/main/java/cn/reactnative/modules/update/NativeCheckOrchestrator.java +43 -11
  39. package/android/src/main/java/cn/reactnative/modules/update/NativeUpdateFlow.java +2 -0
  40. package/android/src/main/java/cn/reactnative/modules/update/SafeZipFile.java +90 -0
  41. package/android/src/main/java/cn/reactnative/modules/update/UpdateContext.java +79 -19
  42. package/android/src/main/java/cn/reactnative/modules/update/UpdateFileUtils.java +21 -0
  43. package/android/src/main/java/cn/reactnative/modules/update/UpdateModuleImpl.java +33 -2
  44. package/android/src/main/java/cn/reactnative/modules/update/UpdateModuleSupport.java +1 -0
  45. package/android/src/newarch/cn/reactnative/modules/update/UpdateModule.java +5 -0
  46. package/android/src/oldarch/cn/reactnative/modules/update/UpdateModule.java +5 -0
  47. package/cpp/patch_core/archive_limits.h +38 -0
  48. package/cpp/patch_core/install_record.h +36 -0
  49. package/cpp/update_flow_core/flow_json.h +1 -0
  50. package/cpp/update_flow_core/update_flow_core.cpp +41 -7
  51. package/cpp/update_flow_core/update_flow_core.h +9 -0
  52. package/cpp/update_flow_core/update_flow_jni.cpp +12 -0
  53. package/harmony/pushy/src/main/cpp/PushyTurboModule.cpp +2 -0
  54. package/harmony/pushy/src/main/cpp/pushy.cpp +37 -0
  55. package/harmony/pushy/src/main/ets/ArchiveLimits.ts +83 -0
  56. package/harmony/pushy/src/main/ets/DownloadTask.ts +126 -30
  57. package/harmony/pushy/src/main/ets/InstallRecord.ts +129 -0
  58. package/harmony/pushy/src/main/ets/NativeCheckOrchestrator.ts +24 -2
  59. package/harmony/pushy/src/main/ets/NativePatchCore.ts +5 -0
  60. package/harmony/pushy/src/main/ets/PushyTurboModule.ts +12 -0
  61. package/harmony/pushy/src/main/ets/UpdateContext.ts +78 -15
  62. package/harmony/pushy.har +0 -0
  63. package/ios/RCTPushy/RCTPushy.mm +384 -25
  64. package/ios/RCTPushy/RCTPushyDownloader.mm +32 -0
  65. package/package.json +25 -2
  66. package/src/NativePushy.ts +13 -0
  67. package/src/client.ts +288 -47
  68. package/src/core.ts +17 -3
  69. package/src/error.ts +3 -0
  70. package/src/errorReporting.ts +136 -0
  71. package/src/index.ts +14 -0
  72. package/src/locales/en.ts +3 -0
  73. package/src/locales/zh.ts +2 -0
  74. package/src/metadata.ts +166 -0
  75. package/src/provider.tsx +52 -17
  76. package/src/type.ts +29 -0
  77. package/src/updateFlowCore.ts +95 -4
  78. package/src/utils.ts +31 -19
  79. package/.gitmodules +0 -6
  80. package/BUNDLEHASH_MIGRATION.md +0 -355
  81. package/NATIVE_CHECKUPDATE_DESIGN.md +0 -539
  82. package/NATIVE_CHECK_FOLLOWUPS.md +0 -514
  83. package/android/jni/HDiffPatch/test/_private_searchBestParams.cpp +0 -301
  84. package/android/jni/HDiffPatch/test/hpatchz_test.cpp +0 -292
  85. package/android/jni/HDiffPatch/test/testHashClash.cpp +0 -436
  86. package/android/jni/HDiffPatch/test/unit_test.cpp +0 -417
  87. package/biome.json +0 -59
  88. package/cpp/patch_core/tests/fixtures/rawstored.lzma2label.patch.bin +0 -0
  89. package/cpp/patch_core/tests/fixtures/rawstored.new.bin +0 -0
  90. package/cpp/patch_core/tests/fixtures/rawstored.old.bin +0 -0
  91. package/cpp/patch_core/tests/fixtures/v96.hbc +0 -0
  92. package/cpp/patch_core/tests/fixtures/v96.meta.json +0 -1
  93. package/cpp/patch_core/tests/fixtures/v96.streampatch.bin +0 -0
  94. package/cpp/patch_core/tests/fixtures/v96.t.hbc +0 -0
  95. package/cpp/patch_core/tests/fixtures/v96.tpatch.bin +0 -0
  96. package/cpp/patch_core/tests/fixtures/v96.tstreampatch.bin +0 -0
  97. package/cpp/patch_core/tests/fixtures/v96b.hbc +0 -0
  98. package/cpp/patch_core/tests/fixtures/v98.hbc +0 -0
  99. package/cpp/patch_core/tests/fixtures/v98.t.hbc +0 -0
  100. package/cpp/patch_core/tests/fixtures/v98b.hbc +0 -0
  101. package/cpp/patch_core/tests/fixtures/v98b.t.hbc +0 -0
  102. package/cpp/patch_core/tests/hbc_transform_test.cpp +0 -384
  103. package/cpp/patch_core/tests/patch_core_test.cpp +0 -970
  104. package/cpp/update_flow_core/tests/flow_vectors.json +0 -1401
  105. package/cpp/update_flow_core/tests/update_flow_core_test.cpp +0 -317
  106. package/scripts/check-expo-version.js +0 -92
@@ -1,417 +0,0 @@
1
- //unit_test.cpp
2
- // for unitTest
3
- //
4
- /*
5
- The MIT License (MIT)
6
- Copyright (c) 2012-2017 HouSisong
7
-
8
- Permission is hereby granted, free of charge, to any person
9
- obtaining a copy of this software and associated documentation
10
- files (the "Software"), to deal in the Software without
11
- restriction, including without limitation the rights to use,
12
- copy, modify, merge, publish, distribute, sublicense, and/or sell
13
- copies of the Software, and to permit persons to whom the
14
- Software is furnished to do so, subject to the following
15
- conditions:
16
-
17
- The above copyright notice and this permission notice shall be
18
- included in all copies of the Software.
19
-
20
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
22
- OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
24
- HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
25
- WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
26
- FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
27
- OTHER DEALINGS IN THE SOFTWARE.
28
- */
29
-
30
- #include <iostream>
31
- #include <string>
32
- #include <vector>
33
- #include <time.h>
34
- #include <stdio.h>
35
- #include <string.h>
36
- #include <stddef.h>//for ptrdiff_t
37
- #include <stdlib.h>
38
- #include "math.h"
39
- #include "../libHDiffPatch/HDiff/diff.h"
40
- #include "../libHDiffPatch/HPatch/patch.h"
41
- typedef unsigned char TByte;
42
- typedef ptrdiff_t TInt;
43
- typedef size_t TUInt;
44
- const long kRandTestCount=20000;
45
- //#define _AttackPacth_ON
46
-
47
- //===== select compress plugin =====
48
- #define _CompressPlugin_no
49
- //#define _CompressPlugin_zlib
50
- //#define _CompressPlugin_bz2
51
- //#define _CompressPlugin_lzma
52
- //#define _CompressPlugin_lzma2
53
- //#define _CompressPlugin_lz4
54
- //#define _CompressPlugin_lz4hc
55
- //#define _CompressPlugin_zstd
56
- //#define _CompressPlugin_brotli
57
- //#define _CompressPlugin_lzham
58
-
59
- #define IS_NOTICE_compress_canceled 0 //for test, close compress fail notice
60
- #define IS_REUSE_compress_handle 1 //for test, must in single thread
61
- #include "../compress_plugin_demo.h"
62
- #include "../decompress_plugin_demo.h"
63
-
64
-
65
- #ifdef _CompressPlugin_no
66
- const hdiff_TCompress* compressPlugin=0;
67
- hpatch_TDecompress* decompressPlugin=0;
68
- #endif
69
- #ifdef _CompressPlugin_zlib
70
- const hdiff_TCompress* compressPlugin=&zlibCompressPlugin.base;
71
- hpatch_TDecompress* decompressPlugin=&zlibDecompressPlugin;
72
- #endif
73
- #ifdef _CompressPlugin_bz2
74
- const hdiff_TCompress* compressPlugin=&bz2CompressPlugin.base;
75
- hpatch_TDecompress* decompressPlugin=&bz2DecompressPlugin;
76
- #endif
77
- #ifdef _CompressPlugin_lzma
78
- const hdiff_TCompress* compressPlugin=&lzmaCompressPlugin.base;
79
- hpatch_TDecompress* decompressPlugin=&lzmaDecompressPlugin;
80
- #endif
81
- #ifdef _CompressPlugin_lzma2
82
- const hdiff_TCompress* compressPlugin=&lzma2CompressPlugin.base;
83
- hpatch_TDecompress* decompressPlugin=&lzma2DecompressPlugin;
84
- #endif
85
- #ifdef _CompressPlugin_lz4
86
- const hdiff_TCompress* compressPlugin=&lz4CompressPlugin.base;
87
- hpatch_TDecompress* decompressPlugin=&lz4DecompressPlugin;
88
- #endif
89
- #ifdef _CompressPlugin_lz4hc
90
- const hdiff_TCompress* compressPlugin=&lz4hcCompressPlugin.base;
91
- hpatch_TDecompress* decompressPlugin=&lz4DecompressPlugin;
92
- #endif
93
- #ifdef _CompressPlugin_zstd
94
- const hdiff_TCompress* compressPlugin=&zstdCompressPlugin.base;
95
- hpatch_TDecompress* decompressPlugin=&zstdDecompressPlugin;
96
- #endif
97
- #ifdef _CompressPlugin_brotli
98
- const hdiff_TCompress* compressPlugin=&brotliCompressPlugin.base;
99
- hpatch_TDecompress* decompressPlugin=&brotliDecompressPlugin;
100
- #endif
101
- #ifdef _CompressPlugin_lzham
102
- const hdiff_TCompress* compressPlugin=&lzhamCompressPlugin.base;
103
- hpatch_TDecompress* decompressPlugin=&lzhamDecompressPlugin;
104
- #endif
105
-
106
- int testCompress(const char* str,const char* error_tag){
107
- assert( ((compressPlugin==0)&&(decompressPlugin==0))
108
- ||((compressPlugin!=0)&&(decompressPlugin!=0)));
109
- if (compressPlugin==0) return 0;
110
- assert(decompressPlugin->is_can_open(compressPlugin->compressType()));
111
-
112
- const TByte* data=(const TByte*)str;
113
- const size_t dataSize=strlen(str);
114
- std::vector<TByte> code((size_t)compressPlugin->maxCompressedSize(dataSize));
115
- size_t codeSize=hdiff_compress_mem(compressPlugin,code.data(),code.data()+code.size(),
116
- data,data+dataSize);
117
- if (codeSize>code.size()) {
118
- printf("\n testCompress compress error!!! tag:%s\n",error_tag); return 1; }
119
- code.resize(codeSize);
120
-
121
- std::vector<TByte> undata(dataSize);
122
- if (!hpatch_deccompress_mem(decompressPlugin,code.data(),code.data()+code.size(),
123
- undata.data(),undata.data()+undata.size())) {
124
- printf("\n testCompress decompress error!!! tag:%s\n",error_tag); return 1; }
125
- if (0!=memcmp(str,undata.data(),undata.size())) {
126
- printf("\n testCompress decompress data error!!! tag:%s\n",error_tag); return 1; }
127
- return 0;
128
- }
129
-
130
-
131
- static bool _patch_mem_stream(TByte* newData,TByte* newData_end,
132
- const TByte* oldData,const TByte* oldData_end,
133
- const TByte* diff,const TByte* diff_end){
134
- struct hpatch_TStreamOutput out_newStream;
135
- struct hpatch_TStreamInput oldStream;
136
- struct hpatch_TStreamInput diffStream;
137
- mem_as_hStreamOutput(&out_newStream,newData,newData_end);
138
- mem_as_hStreamInput(&oldStream,oldData,oldData_end);
139
- mem_as_hStreamInput(&diffStream,diff,diff_end);
140
-
141
- return 0!=patch_stream(&out_newStream,&oldStream,&diffStream);
142
- }
143
-
144
- static bool check_diff_stream(const TByte* newData,const TByte* newData_end,
145
- const TByte* oldData,const TByte* oldData_end,
146
- const TByte* diff,const TByte* diff_end){
147
- std::vector<TByte> testNewData(newData_end-newData);
148
- TByte* testNewData0=testNewData.data();
149
-
150
- if (!_patch_mem_stream(testNewData0,testNewData0+testNewData.size(),
151
- oldData,oldData_end,diff,diff_end))
152
- return false;
153
- for (TUInt i=0; i<(TUInt)testNewData.size(); ++i) {
154
- if (testNewData[i]!=newData[i])
155
- return false;
156
- }
157
- return true;
158
- }
159
-
160
-
161
- #ifdef _AttackPacth_ON
162
- long attackPacth(TByte* out_newData,TByte* out_newData_end,
163
- const TByte* oldData,const TByte* oldData_end,
164
- const TByte* diffData,const TByte* diffData_end,
165
- const char* error_tag,bool isDiffz){
166
- if (isDiffz){
167
- patch_decompress_mem(out_newData,out_newData_end,oldData,oldData_end,
168
- diffData,diffData_end,decompressPlugin);
169
- }else{
170
- hpatch_BOOL rt0=patch(out_newData,out_newData_end,oldData,oldData_end,diffData,diffData_end);
171
- hpatch_BOOL rt1=_patch_mem_stream(out_newData,out_newData_end,oldData,oldData_end,diffData,diffData_end);
172
- if (rt0!=rt1){
173
- printf("\n attackPacth error!!! tag:%s\n",error_tag);
174
- return 1;
175
- }
176
- }
177
- return 0;
178
- }
179
-
180
- long attackPacth(TInt newSize,const TByte* oldData,const TByte* oldData_end,
181
- const TByte* _diffData,const TByte* _diffData_end,int seed,bool isDiffz){
182
- char tag[250]="\0";
183
- srand(seed);
184
- const long kLoopCount=1000;
185
- long exceptionCount=0;
186
- std::vector<TByte> _newData(newSize);
187
- TByte* newData=_newData.data();
188
- TByte* newData_end=newData+_newData.size();
189
- const TInt diffSize=_diffData_end-_diffData;
190
- std::vector<TByte> new_diffData(diffSize);
191
- TByte* diffData=new_diffData.data();
192
- TByte* diffData_end=diffData+diffSize;
193
- try {
194
- for (long i=0; i<kLoopCount; ++i) {
195
- sprintf(tag, "attackPacth exceptionCount=%ld testSeed=%d i=%ld",exceptionCount,seed,i);
196
- memcpy(diffData,_diffData,_diffData_end-_diffData);
197
- const long randCount=(long)(1+rand()*(1.0/RAND_MAX)*rand()*(1.0/RAND_MAX)*diffSize/3);
198
- for (long r=0; r<randCount; ++r){
199
- diffData[rand()%diffSize]=rand();
200
- }
201
- exceptionCount+=attackPacth(newData,newData_end,oldData,oldData_end,diffData,diffData_end,tag,isDiffz);
202
- }
203
- return exceptionCount;
204
- } catch (...) {
205
- printf("exception!!! tag:%s\n",tag);
206
- return exceptionCount+1;
207
- }
208
- }
209
- #endif
210
-
211
- struct TVectorStreamOutput:public hpatch_TStreamOutput{
212
- explicit TVectorStreamOutput(std::vector<TByte>& _dst):dst(_dst){
213
- this->streamImport=this;
214
- this->streamSize=~(hpatch_StreamPos_t)0;
215
- this->read_writed=0;
216
- this->write=_write;
217
- }
218
- static hpatch_BOOL _write(const hpatch_TStreamOutput* stream,
219
- const hpatch_StreamPos_t writeToPos,
220
- const unsigned char* data,const unsigned char* data_end){
221
- TVectorStreamOutput* self=(TVectorStreamOutput*)stream->streamImport;
222
- std::vector<TByte>& dst=self->dst;
223
- size_t writeLen=(size_t)(data_end-data);
224
- if (writeToPos>dst.size()) return false;
225
- if (dst.size()==writeToPos){
226
- dst.insert(dst.end(),data,data_end);
227
- }else{
228
- if (writeToPos+writeLen!=(size_t)(writeToPos+writeLen)) return false;
229
- if (dst.size()<writeToPos+writeLen)
230
- dst.resize((size_t)(writeToPos+writeLen));
231
- memcpy(&dst[(size_t)writeToPos],data,writeLen);
232
- }
233
- return true;
234
- }
235
- std::vector<TByte>& dst;
236
- };
237
-
238
- long test(const TByte* newData,const TByte* newData_end,
239
- const TByte* oldData,const TByte* oldData_end,const char* tag,size_t* out_diffSize=0){
240
- printf("%s newSize:%ld oldSize:%ld ",tag, (long)(newData_end-newData), (long)(oldData_end-oldData));
241
- long result=0;
242
- {//test diffz stream
243
- std::vector<TByte> diffData;
244
- struct hpatch_TStreamInput newStream;
245
- struct hpatch_TStreamInput oldStream;
246
- TVectorStreamOutput out_diffStream(diffData);
247
- mem_as_hStreamInput(&newStream,newData,newData_end);
248
- mem_as_hStreamInput(&oldStream,oldData,oldData_end);
249
-
250
- create_compressed_diff_stream(&newStream,&oldStream,&out_diffStream,compressPlugin,1<<4);
251
-
252
- struct hpatch_TStreamInput in_diffStream;
253
- mem_as_hStreamInput(&in_diffStream,diffData.data(),diffData.data()+diffData.size());
254
- if (!check_compressed_diff(newData,newData_end,oldData,oldData_end,
255
- diffData.data(),diffData.data()+diffData.size(),decompressPlugin)){
256
- printf("\n diffz stream error!!! tag:%s\n",tag);
257
- ++result;
258
- }else{
259
- printf(" diffzStream:%ld", (long)(diffData.size()));
260
- #ifdef _AttackPacth_ON
261
- long exceptionCount=attackPacth(newData_end-newData,oldData,oldData_end,
262
- diffData.data(),diffData.data()+diffData.size(),rand(),true);
263
- if (exceptionCount>0) return exceptionCount;
264
- #endif
265
- }
266
- }
267
- {//test diffz
268
- std::vector<TByte> diffData;
269
- create_compressed_diff(newData,newData_end,oldData,oldData_end,diffData,compressPlugin);
270
- if (!check_compressed_diff(newData,newData_end,oldData,oldData_end,
271
- diffData.data(),diffData.data()+diffData.size(),decompressPlugin)){
272
- printf("\n diffz error!!! tag:%s\n",tag);
273
- ++result;
274
- }else{
275
- printf(" diffz:%ld", (long)(diffData.size()));
276
- #ifdef _AttackPacth_ON
277
- long exceptionCount=attackPacth(newData_end-newData,oldData,oldData_end,
278
- diffData.data(),diffData.data()+diffData.size(),rand(),true);
279
- if (exceptionCount>0) return exceptionCount;
280
- #endif
281
- }
282
- }
283
- {//test diff
284
- std::vector<TByte> diffData;
285
- create_diff(newData,newData_end,oldData,oldData_end, diffData);
286
- if (out_diffSize!=0)
287
- *out_diffSize=diffData.size();
288
- if ((!check_diff(newData,newData_end,oldData,oldData_end,diffData.data(),diffData.data()+diffData.size()))
289
- ||(!check_diff_stream(newData,newData_end,oldData,oldData_end,
290
- diffData.data(),diffData.data()+diffData.size())) ){
291
- printf("\n error!!! tag:%s\n",tag);
292
- ++result;
293
- }else{
294
- printf(" diff:%ld\n", (long)(diffData.size()));
295
- #ifdef _AttackPacth_ON
296
- long exceptionCount=attackPacth(newData_end-newData,oldData,oldData_end,
297
- diffData.data(),diffData.data()+diffData.size(),rand(),false);
298
- if (exceptionCount>0) return exceptionCount;
299
- #endif
300
- }
301
- }
302
- return result;
303
- }
304
-
305
-
306
-
307
- static inline long test(const char* newStr,const char* oldStr,const char* error_tag){
308
- const TByte* newData=(const TByte*)newStr;
309
- const TByte* oldData=(const TByte*)oldStr;
310
- return test(newData,newData+strlen(newStr),oldData,oldData+strlen(oldStr),error_tag);
311
- }
312
-
313
-
314
- void setRandDataSize(int kMaxDataSize,std::vector<TByte>& oldData,std::vector<TByte>& newData,
315
- double sunSizeMin,double subSizeMax){
316
- const TInt oldSize=(TInt)(rand()*(1.0/RAND_MAX)*rand()*(1.0/RAND_MAX)*kMaxDataSize);
317
- const TInt newSize=(TInt)(oldSize*(sunSizeMin+rand()*(1.0/RAND_MAX)*(subSizeMax-sunSizeMin)));
318
- newData.resize(newSize);
319
- oldData.resize(oldSize);
320
- }
321
-
322
- void setRandData(std::vector<TByte>& data){
323
- for (TInt i=0; i<(TInt)data.size(); ++i)
324
- data[i]=rand();
325
- }
326
-
327
-
328
- int main(int argc, const char * argv[]){
329
- clock_t time1=clock();
330
- long errorCount=0;
331
- errorCount+=testCompress("","c1");
332
- errorCount+=testCompress("1","c2");
333
- errorCount+=testCompress("12","c3");
334
- errorCount+=testCompress("123","c4");
335
- errorCount+=testCompress("123456789876543212345677654321234567765432","c5");
336
-
337
- errorCount+=test("", "", "1");
338
- errorCount+=test("", "1", "2");
339
- errorCount+=test("1", "", "3");
340
- errorCount+=test("1", "1", "4");
341
- errorCount+=test("22", "11", "5");
342
- errorCount+=test("22", "22", "6");
343
- errorCount+=test("1234567890", "1234567890", "7");
344
- errorCount+=test("123456789876543212345677654321234567765432", "asadsdasfefw45fg4gacasc234fervsvdfdsfef4g4gr", "8");
345
- errorCount+=test("123456789876543212345677654321234567765432asadsdasfefw45fg4gacasc234fervsvdfdsfef4g4gr", "asadsdasfefw45fg4gacasc234fervsvdfdsfef4g4gr", "9");
346
- errorCount+=test("asadsdasfefw45fg4gacasc234fervsvdfdsfef4g4gr123456789876543212345677654321234567765432", "asadsdasfefw45fg4gacasc234fervsvdfdsfef4g4gr", "10");
347
- errorCount+=test("a123456789876543212345677654321234567765432asadsdasfefw45fg4gacasc234fervsvdfdsfef4g4gr", "asadsdasfefw45fg4gacasc234fervsvdfdsfef4g4gr", "11");
348
- errorCount+=test("123456789876543212345677654321234567765432asadsdasfefw45fg4gacasc234fervsvdfdsfef4g4gr1", "asadsdasfefw45fg4gacasc234fervsvdfdsfef4g4gr", "12");
349
- errorCount+=test("a123456789876543212345677654321234567765432asadsdasfefw45fg4gacasc234fervsvdfdsfef4g4gr1", "asadsdasfefw45fg4gacasc234fervsvdfdsfef4g4gr", "13");
350
-
351
- {
352
- const char* _strData14="a123456789876543212345677654321234567765432asadsdasfefw45fg4gacasc234fervsvdfdsfef4g4gr1";
353
- const TByte* data14=(const TByte*)_strData14;
354
- const size_t dataSize=strlen(_strData14);
355
- size_t diffSize14=0;
356
- errorCount+=test(data14, data14+dataSize,data14, data14+dataSize, "14",&diffSize14);
357
- if (diffSize14>=dataSize){
358
- ++errorCount;
359
- printf("error!!! tag:%s\n","14 test diff size");
360
- }
361
- }
362
-
363
- const int kMaxDataSize=1024*16;
364
-
365
- std::vector<int> seeds(kRandTestCount);
366
- srand(0);
367
- for (int i=0; i<kRandTestCount; ++i)
368
- seeds[i]=rand();
369
-
370
- double sumNewSize=0;
371
- double sumOldSize=0;
372
- double sumDiffSize=0;
373
- std::vector<TByte> _newData;
374
- std::vector<TByte> _oldData;
375
- for (TInt i=0; i<kRandTestCount; ++i) {
376
- char tag[256];
377
- #if defined(_MSC_VER)&&(_MSC_VER>=1400) //VC2005
378
- sprintf_s(tag,256, "error==%ld testSeed=%d",errorCount,seeds[i]);
379
- #else
380
- sprintf(tag, "error==%ld testSeed=%d",errorCount,seeds[i]);
381
- #endif
382
-
383
- srand(seeds[i]);
384
-
385
- setRandDataSize(kMaxDataSize,_oldData,_newData,0.7,1.5);
386
- setRandData(_oldData);
387
- setRandData(_newData);
388
- const TInt oldSize=(TInt)_oldData.size();
389
- const TInt newSize=(TInt)_newData.size();
390
- const TInt kMaxCopyCount=(TInt)sqrt((double)oldSize);
391
- TByte* newData=_newData.data();
392
- TByte* oldData=_oldData.data();
393
- const TInt copyCount=0+(TInt)((1-rand()*(1.0/RAND_MAX)*rand()*(1.0/RAND_MAX))*kMaxCopyCount*4);
394
- const TInt kMaxCopyLength=(TInt)(1+rand()*(1.0/RAND_MAX)*kMaxCopyCount*4);
395
- for (TInt ci=0; ci<copyCount; ++ci) {
396
- const TInt length=1+(TInt)(rand()*(1.0/RAND_MAX)*kMaxCopyLength);
397
- if ((length>oldSize*4/5)||(length>newSize*4/5)) {
398
- continue;
399
- }
400
- const TInt oldPos=(oldSize-length==0)?0:(TInt)(rand()*(1.0/RAND_MAX)*(oldSize-length));
401
- const TInt newPos=(newSize-length==0)?0:(TInt)(rand()*(1.0/RAND_MAX)*(newSize-length));
402
- memcpy(&newData[0]+newPos, &oldData[0]+oldPos, length);
403
- }
404
- size_t diffSize=0;
405
- errorCount+=test(&newData[0],&newData[0]+newSize,&oldData[0],&oldData[0]+oldSize,tag,&diffSize);
406
- sumNewSize+=newSize;
407
- sumOldSize+=oldSize;
408
- sumDiffSize+=diffSize;
409
- }
410
-
411
- printf("\nchecked:%ld errorCount:%ld\n",kRandTestCount,errorCount);
412
- printf("newSize:100%% oldSize:%2.2f%% diffSize:%2.2f%%\n",sumOldSize*100.0/sumNewSize,sumDiffSize*100.0/sumNewSize);
413
- clock_t time2=clock();
414
- printf("\nrun time:%.1f s\n",(time2-time1)*(1.0/CLOCKS_PER_SEC));
415
-
416
- return (int)errorCount;
417
- }
package/biome.json DELETED
@@ -1,59 +0,0 @@
1
- {
2
- "$schema": "https://biomejs.dev/schemas/2.5.5/schema.json",
3
- "vcs": {
4
- "enabled": true,
5
- "clientKind": "git",
6
- "useIgnoreFile": true
7
- },
8
- "files": {
9
- "ignoreUnknown": true,
10
- "includes": [
11
- "**/*.js",
12
- "**/*.jsx",
13
- "**/*.ts",
14
- "**/*.tsx",
15
- "**/*.json",
16
- "!**/node_modules",
17
- "!**/android",
18
- "!**/ios",
19
- "!**/dist",
20
- "!**/harmony",
21
- "!**/.tmp"
22
- ]
23
- },
24
- "formatter": {
25
- "enabled": true,
26
- "indentStyle": "space",
27
- "indentWidth": 2,
28
- "lineWidth": 80
29
- },
30
- "assist": {
31
- "actions": {
32
- "source": {
33
- "organizeImports": "on"
34
- }
35
- }
36
- },
37
- "linter": {
38
- "enabled": true,
39
- "rules": {
40
- "preset": "recommended",
41
- "suspicious": {
42
- "noExplicitAny": "off"
43
- },
44
- "style": {
45
- "noNonNullAssertion": "off"
46
- },
47
- "complexity": {
48
- "noUselessFragments": "off"
49
- }
50
- }
51
- },
52
- "javascript": {
53
- "formatter": {
54
- "quoteStyle": "single",
55
- "jsxQuoteStyle": "double",
56
- "trailingCommas": "es5"
57
- }
58
- }
59
- }
@@ -1 +0,0 @@
1
- {"v":1,"hbcVersion":96,"layout":{"counts":19,"sections":[[2,16,[[0,0,25],[8,0,25]]],[3,4,[]],[4,4,[]],[5,4,[[0,1,23]]],[6,8,[[0,0,32]]],[7,1,[]],[12,1,[]],[13,1,[]],[14,1,[]],[8,8,[[0,0,32]]],[9,1,[]],[10,8,[[0,0,32]]],[11,1,[]],[16,8,[]],[17,8,[]]]}}