Commit Graph
228 Commits
Author SHA1 Message Date
Matthew Duggan c53b42311d COMMON: Fix path split+join combinations, add tests for same
This resolves multiple scenarios where a path ends up with a trailing
separator.
2022-12-31 17:57:07 +09:00
Cameron Cawley 4002c7bdde COMMON: Add a version of Common::Array::resize with a fill value 2022-12-19 14:33:07 +02:00
Cameron Cawley a55361b65d COMMON: Add Common::Array::swap() 2022-12-18 23:36:09 +02:00
Cameron Cawley 28d7b361ea COMMON: Move more file format code into common/formats 2022-12-11 22:33:23 +01:00
Cameron Cawley 0581301b24 COMMON: Move huffman.h back out of the compression directory 2022-12-11 22:33:23 +01:00
Eugene Sandulenko fb7095f5a4 COMMON: Move all compression-related files to a separate directory 2022-12-01 11:53:02 +01:00
Vladimir Serbinenko 357249fb5a COMMON: Split slow and fast CRC implementation
They have almost nothing in common. And we probably want to kill slow
implementation anyway now that we have tests
2022-11-29 01:05:31 +01:00
Vladimir Serbinenko 05f1a0df51 COMMON: Remove the need for most reflecting when initing reflected table
Instead reflect the polynomial and change the shifts. Also removes the
need for explicit init.

This makes our crc more similar to its standard implementation
2022-11-29 01:05:31 +01:00
Vladimir Serbinenko 35bac4e58c COMMON: Add tests for CRC 2022-11-29 01:05:31 +01:00
Sergio d136a5f54c COMMON: fix String::rfind for default value of pos (max value of size_t) 2022-11-26 23:13:42 +02:00
Cameron Cawley 3441c7230d COMMON: Fix handling escaped percents in Common::U32String::format 2022-11-20 14:23:30 +01:00
Cameron Cawley 29024cded7 COMMON: Fix handling negative numbers in Common::U32String::format 2022-11-20 14:23:30 +01:00
Le Philousophe ab12e7fe01 COMMON: Fix a missing str.h include
It's not included anymore in util.h
2022-10-30 19:38:35 +01:00
Le Philousophe 6524f7beb5 COMMON: Forbid use of unsafe sprintf and vsprintf 2022-10-23 22:46:19 +02:00
Roland van Laar 407902599e TESTS: Fix clang++ warning
./test/common/md5.h:17:3: warning: suspicious concatenation of string literals in an array initialization; did you mean to separate the elements with a comma? [-Wstring-concatenation]
                "345678901234567890"
2022-10-06 19:01:15 +02:00
Roland van Laar 70e715b6f8 TESTS: Fix compiler warnings integer comparisons
Use suffix `U` for integers when comparing results of `size`.
Use uints in the forloops.
2022-10-06 17:41:41 +02:00
Roland van Laar 07478b38be TESTS: plug memory leaks in span tests
Declare dataPtr as a byte pointer instead of a void pointer to
be able to delete it at the end of the test.
2022-10-06 16:12:27 +02:00
Roland van Laar e78a88e2fb TESTS: plug memory leaks
Use `clear` instead of `release` where possible.
Both clean up the span object. They differ in that `release` returns a pointer to
the internal data and `clear` destroys the internal data.
2022-10-05 18:11:10 +02:00
Cameron Cawley 0d37729ff7 COMMON: Fix reading and writing doubles from streams with older ARM toolchains 2022-07-02 12:49:22 +02:00
elasota 9fa32ac47d COMMON: Fix WeakPtr preventing object deletion 2022-04-25 18:20:19 -07:00
Matthew Duggan ddee0e76f9 COMMON: INIFile bugfixes and unit tests
This adds a lot more unit tests for Common::INIFile and fixes some small
problems identified during their creation.  Specifically:

* addSection() did not check the validity of the section name, which meant it
  was possible to create a section that could not then be operated on by the
  other functions (which all check validity)
* If allowNonEnglishCharacters was set, it was possible to create a key or
  section name starting with '[' or '#', or including a carriage return.  This
  would not read back in correctly.
* Blank section and key names were considered valid, but neither would be
  read back in correctly.
* The struct documentation did not mention whitespcae handling or that comments
  include the '#' and carriage return.
2022-04-10 19:41:06 +03:00
Matthew Duggan a74b081973 TEST: Add more tests for Common::INIFile
My initial tests were quite minimal as I was trying to fix the build.  Now more
of the basic INIFile functionality is tested.
2022-03-25 18:16:07 +09:00
Matthew Duggan 97a0e8d2d9 TEST: Add tests for Common::INIFile
This is partly an attempt to fix the build on debian and windows as apparently
the INIFile class is not being linked in to the tests.
2022-03-25 17:35:51 +09:00
Eugene Sandulenko 55a171867e DEVTOOLS: COMPANION: Added test for higher Unicode characters 2021-10-31 23:00:35 +02:00
Eugene Sandulenko 7fa0d97e32 DEVTOOLS: Added more tests for punycode 2021-10-31 19:27:34 +02:00
Eugene Sandulenko 798058999d TESTS: Added test for common/punycode.h 2021-10-31 16:37:53 +02:00
Eugene Sandulenko c544e5119b COMMON: Remove USE_CXX11 checks, it is now always present 2021-10-31 11:52:29 +02:00
Le Philousophe c201ddfcf4 TEST: Fix encoding test adding a '\0'
Use sizeof at the same time to avoid hardcoded constants
2021-08-08 13:56:00 +02:00
Orgad Shaneh a05e54f00c JANITORIAL: Remove trailing whitespaces 2021-05-04 11:46:30 +03:00
Eugene Sandulenko 5e7fe2dc57 JANITORIAL: Replace spaces in indentation with tabs 2021-04-15 21:20:36 +02:00
Le Philousophe 08c46ec41e TESTS: Cleanup allocation in array tests 2021-04-10 23:36:55 +02:00
Le Philousophe 5cdb300534 COMMON: Fix CJK encode/decode and make valgrind quiet
CJK offsets were wrong compared to encodings.dat file and buffers were
read past their end.
Rewrote indexing to make it match the Python script and optimize
slightly
2021-04-10 23:36:55 +02:00
SupSuper fd81f32d6a TESTS: Use getValOrDefault 2021-02-12 02:50:34 +00:00
Vladimir Serbinenko cd8270f039 TEST: Third attempt to fix the tests
Some tests unnecessarily referred to null osystem. Tested with PSP target
2020-11-16 01:51:14 +01:00
Vladimir Serbinenko e3ace27da0 TEST: Second attempt at fixing tests
The framework doesn't understand preprocessor, put preprocessing inside the
tests.
2020-11-16 00:51:22 +01:00
Vladimir Serbinenko a9fe1d7a84 TEST: Skip CJK tests outside of POSIX
They need file access that needs null backend which for now only
peopwely compiles on POSIX.
2020-11-15 23:57:53 +01:00
Vladimir Serbinenko 68a9136e4d COMMON: Rewrite Encoder and drop dependency on iconv (#2586)
Different platforms have different levels of support of encodings and
often have slight variations. We already have tables for most encoding
with only CJK missing. Full transcoding inclusion allows us to get reliable
encoding results independently of platform. The biggest con is the need for
external tables encoding.dat.

It removes a duplicate table for korean in graphics/korfont.cpp
2020-11-15 16:20:35 +01:00
Thierry Crozat a275522f89 COMMON: Add list initialization and move semantics to Array 2020-10-03 15:51:14 +02:00
Vladimir Menshakov 0a4154318c COMMON: implement %c formatter (used in hardware-input.cpp)
Fix invalid descriptor name for half-axis.
Add some tests for U32String::Format.
2020-09-12 11:56:17 +01:00
Vladimir Menshakov 8ddcbf8120 COMMON: Fix warnings about different signedness (uint32/char comparison), remove unused var
Add tests for both str/ustr comparison operators.
2020-09-02 20:35:43 +01:00
Vladimir Menshakov f63f424309 COMMON: Preserve the order of insertion for equal range of the keys. 2020-08-31 18:17:29 +01:00
Bastien Bouclet bb27669026 COMMON: Refill the stream buffer after making a large read
After reading directly from the parent stream, the buffer needs to be
filled with the end of the read data so seeking back in the stream into
the buffered area and reading returns data consistent with the parent
stream.

Fixes bug #11342 (PSP port only).
2020-02-07 18:33:56 +01:00
Jaromir Wysoglad 1346dcc3ef TESTBED: Move encoding conversion tests to testbed
This way it is possible to test the backend conversions too.
2019-08-24 18:12:45 +03:00
Jaromir Wysoglad 5fcd14fbea TEST: Remove tests for ascii transliteration
This can be handled differently by each conversion method.
The "Šáleček" could be transliterated as "Salecek" or as
"S'alecek" or maybe even differently.
2019-08-24 18:12:45 +03:00
Jaromir Wysoglad 3513972e92 TEST: Add tests for Common::Encoding 2019-08-24 18:12:45 +03:00
Bastien Bouclet 0f57aea2df COMMON: Use a prefix table to speed up the Huffman decoder
Symbols for codes shorter than the prefix table index width are stored
in the table. All the entries in the table with an index starting with
the code are set to the symbol value. That way, when decoding it is
possible to get the number of bits corresponding to the table width from
the bitstream and directly find the symbol value. Longer code still need
to be searched for in the codes list.
2019-04-13 16:24:25 +03:00
Bastien Bouclet ae9eeb731f COMMON: Rework the BitStream class to improve its performance
* Fixed peekBits not to seek the underlying stream. Seeking can be slow
  when the stream is a file.
* Changed multi-bit  operations to work on multiple bits at once rather
  than iterating over single-bit operations.

This is an almost direct port of a patch for xoreos provided by DrMcCoy.
2019-04-13 16:24:25 +03:00
Thierry Crozat 563520f5c8 TESTS: Reduce error for double precision math test
If we want to properly test the computation is in double precision,
we should be using a much smaller error than the one used for the
single precision tests.
2019-04-12 01:37:59 +01:00
David Fioramonti 322af3e49a TESTS: Use relative difference for math tests
Also add double template variants and use already defined delta
assert macro.
2019-04-11 17:20:00 -07:00
David Fioramonti cf0e9bfc1b TESTS: further reduce precision for math tests
Since the math is doing subtraction on numbers around 360 and single
precision has about ~7 decimal digits of accuracy we can only
compare numbers to 360.0001 to be safe i'll use 1e-3.
2019-04-11 16:50:07 -07:00