diff --git a/.ecode/project_build.json b/.ecode/project_build.json index 9d1547eaa..d42054499 100644 --- a/.ecode/project_build.json +++ b/.ecode/project_build.json @@ -172,6 +172,20 @@ "command": "ecode", "name": "ecode-release", "working_dir": "${project_root}/bin" + }, + { + "args": "", + "command": "eepp-unit_tests-debug", + "name": "eepp-unit_tests-debug", + "run_in_terminal": true, + "working_dir": "${project_root}/bin/unit_tests" + }, + { + "args": "", + "command": "eepp-unit_tests", + "name": "eepp-unit_tests", + "run_in_terminal": true, + "working_dir": "${project_root}/bin/unit_tests" } ], "var": { diff --git a/.github/workflows/eepp-linux-build-check.yml b/.github/workflows/eepp-linux-build-check.yml index 2de432d09..74f90b237 100644 --- a/.github/workflows/eepp-linux-build-check.yml +++ b/.github/workflows/eepp-linux-build-check.yml @@ -9,6 +9,7 @@ jobs: - name: Checkout repository uses: actions/checkout@v3 with: + ref: ${{ github.ref }} fetch-depth: 2 - name: Checkout submodules run: | @@ -27,10 +28,14 @@ jobs: sudo update-alternatives --set c++ /usr/bin/g++ sudo update-alternatives --config gcc sudo update-alternatives --config g++ - wget https://github.com/premake/premake-core/releases/download/v5.0.0-beta1/premake-5.0.0-beta1-linux.tar.gz - tar xvzf premake-5.0.0-beta1-linux.tar.gz + wget https://github.com/premake/premake-core/releases/download/v5.0.0-beta2/premake-5.0.0-beta2-linux.tar.gz + tar xvzf premake-5.0.0-beta2-linux.tar.gz - name: Build run: | ./premake5 gmake2 cd make/linux - make all -j$(nproc) + make all -j$(nproc) -e config=release_x86_64 + - name: Unit Tests + run: | + cd bin/unit_tests + ./eepp-unit_tests diff --git a/.github/workflows/eepp-macos-build-check.yml b/.github/workflows/eepp-macos-build-check.yml index 377d251af..448ab471c 100644 --- a/.github/workflows/eepp-macos-build-check.yml +++ b/.github/workflows/eepp-macos-build-check.yml @@ -9,6 +9,7 @@ jobs: - name: Checkout repository uses: actions/checkout@v3 with: + ref: ${{ github.ref }} fetch-depth: 2 - name: Checkout submodules run: | @@ -20,3 +21,8 @@ jobs: run: | premake5 gmake2 make -C make/macosx/ -e config=release_arm64 + - name: Unit Tests + run: | + cd bin/unit_tests + ./eepp-unit_tests + diff --git a/.github/workflows/eepp-windows-build-check.yml b/.github/workflows/eepp-windows-build-check.yml index 7e12351ca..83e6f7ddb 100644 --- a/.github/workflows/eepp-windows-build-check.yml +++ b/.github/workflows/eepp-windows-build-check.yml @@ -11,6 +11,7 @@ jobs: - name: Checkout repository uses: actions/checkout@v3 with: + ref: ${{ github.ref }} fetch-depth: 2 - name: Checkout submodules run: | @@ -18,8 +19,8 @@ jobs: - name: Install dependencies shell: powershell run: | - Invoke-WebRequest -Uri "https://github.com/premake/premake-core/releases/download/v5.0.0-beta1/premake-5.0.0-beta1-windows.zip" -OutFile "premake-5.0.0-beta1-windows.zip" - Expand-Archive -DestinationPath . -Path premake-5.0.0-beta1-windows.zip + Invoke-WebRequest -Uri "https://github.com/premake/premake-core/releases/download/v5.0.0-beta2/premake-5.0.0-beta2-windows.zip" -OutFile "premake-5.0.0-beta2-windows.zip" + Expand-Archive -DestinationPath . -Path premake-5.0.0-beta2-windows.zip - name: Create project shell: powershell run: | @@ -27,4 +28,9 @@ jobs: - name: Build shell: cmd run: | - "%MSBUILD_PATH%\MSBuild.exe" .\make\windows\eepp.sln -m /p:Platform="x64" + "%MSBUILD_PATH%\MSBuild.exe" .\make\windows\eepp.sln -m /p:Platform="x64" /p:Configuration="release" + - name: Unit Tests + shell: cmd + run: | + cd bin\unit_tests + ./eepp-unit_tests.exe diff --git a/.gitignore b/.gitignore index 729ca611d..a6eea083d 100644 --- a/.gitignore +++ b/.gitignore @@ -65,3 +65,4 @@ ecode.dmg /.ecode/.prjallowed /.cache/ /compile_commands.json +/bin/unit_tests/eepp-* diff --git a/bin/unit_tests/assets/textformat/chinese.utf16be.crlf.bom.txt b/bin/unit_tests/assets/textformat/chinese.utf16be.crlf.bom.txt new file mode 100644 index 000000000..c62f9bf64 Binary files /dev/null and b/bin/unit_tests/assets/textformat/chinese.utf16be.crlf.bom.txt differ diff --git a/bin/unit_tests/assets/textformat/chinese.utf16be.crlf.nobom.txt b/bin/unit_tests/assets/textformat/chinese.utf16be.crlf.nobom.txt new file mode 100644 index 000000000..b910011a7 Binary files /dev/null and b/bin/unit_tests/assets/textformat/chinese.utf16be.crlf.nobom.txt differ diff --git a/bin/unit_tests/assets/textformat/chinese.utf16be.lf.bom.txt b/bin/unit_tests/assets/textformat/chinese.utf16be.lf.bom.txt new file mode 100644 index 000000000..b2cd81d93 Binary files /dev/null and b/bin/unit_tests/assets/textformat/chinese.utf16be.lf.bom.txt differ diff --git a/bin/unit_tests/assets/textformat/chinese.utf16be.lf.nobom.txt b/bin/unit_tests/assets/textformat/chinese.utf16be.lf.nobom.txt new file mode 100644 index 000000000..dc17d1e5a Binary files /dev/null and b/bin/unit_tests/assets/textformat/chinese.utf16be.lf.nobom.txt differ diff --git a/bin/unit_tests/assets/textformat/chinese.utf16le.crlf.bom.txt b/bin/unit_tests/assets/textformat/chinese.utf16le.crlf.bom.txt new file mode 100644 index 000000000..eb2201629 Binary files /dev/null and b/bin/unit_tests/assets/textformat/chinese.utf16le.crlf.bom.txt differ diff --git a/bin/unit_tests/assets/textformat/chinese.utf16le.crlf.nobom.txt b/bin/unit_tests/assets/textformat/chinese.utf16le.crlf.nobom.txt new file mode 100644 index 000000000..a8067e78d Binary files /dev/null and b/bin/unit_tests/assets/textformat/chinese.utf16le.crlf.nobom.txt differ diff --git a/bin/unit_tests/assets/textformat/chinese.utf16le.lf.bom.txt b/bin/unit_tests/assets/textformat/chinese.utf16le.lf.bom.txt new file mode 100644 index 000000000..2918071f2 Binary files /dev/null and b/bin/unit_tests/assets/textformat/chinese.utf16le.lf.bom.txt differ diff --git a/bin/unit_tests/assets/textformat/chinese.utf16le.lf.nobom.txt b/bin/unit_tests/assets/textformat/chinese.utf16le.lf.nobom.txt new file mode 100644 index 000000000..85927b1c6 Binary files /dev/null and b/bin/unit_tests/assets/textformat/chinese.utf16le.lf.nobom.txt differ diff --git a/bin/unit_tests/assets/textformat/chinese.utf8.crlf.bom.txt b/bin/unit_tests/assets/textformat/chinese.utf8.crlf.bom.txt new file mode 100644 index 000000000..1facdc4f3 --- /dev/null +++ b/bin/unit_tests/assets/textformat/chinese.utf8.crlf.bom.txt @@ -0,0 +1,48 @@ +第一回 甄士隱夢幻識通靈 賈雨村風塵懷閨秀 + + 【甲戌、庚、蒙批:此開卷第一回也。作者自云:因曾歷過一番夢幻之後,故將真事隱去, +而借通靈之說,撰此《石頭記》一書也。故曰「甄士隱夢幻識通靈」。但書中所記何事,又因何 +而撰是書哉?自又云:今風塵碌碌,一事無成,忽念及當日所有之女子,一一細推了去,覺其行 +止見識,皆出於我之上。何我堂堂之鬚眉,曾不若彼裙釵哉!實愧則有餘,悔又無益之大無可奈 +何之日也!當此時,則自欲將已往所賴,上賴天恩,下承祖德,錦衣紈絝之時、飫甘饜美肥之日, +背父母教育之恩,負師兄規訓之德,已至今日一事無成、半生潦倒之罪,編述一記,以告普天下 +人。我之罪固不能免,然閨閣中本自歷歷有人,萬不可因我之不肖,自護其短,則一併使其泯滅 +也。雖今日之茆椽蓬牖,瓦灶繩床,其風晨月夕,階柳庭花,亦未有傷於我之襟懷筆墨者。雖我 +未學,下筆無文,何爲不用假語村言,敷演出一段故事來,以悅人之耳目哉。故曰「風塵懷閨 +秀」,乃是第一回題綱正義也。開卷即曰「風塵懷閨秀」,則知作者本意原爲記述當日閨友閨情, +並非怨世駡時之書矣。雖一時有涉於世態,然亦不得不叙者,但非其本旨耳,閱者切記之。詩曰: + + 【浮生著甚苦奔忙?盛席華筵終散場。】 + 【悲喜千般同幻渺,古今一夢盡荒唐。】 + 【謾言紅袖啼痕重,更有情痴抱恨長。】 + 【字字看來皆是血,十年辛苦不尋常!】 + + 【楊藏、庚辰、夢覺、舒序批:此回中凡用夢用幻等字,是提醒閱者眼目,亦是此書立意本 +旨。】〈按:此兩段回前批语常被混入正文。故雖為批語,仍錄於此。〉 + + 列位看官,你道此書從何而來?說起根由雖近荒唐,細諳則深有趣味。待在下將此來歷注明, +方使聞者了然不惑。 + + 原來,當年女媧氏煉石補天之時,於大荒山無稽崖煉成高經[1]十二丈,方經[2]二十四丈頑 +石三萬六千五百零一塊。媧皇氏只用了三萬六千五百塊,只單單剩了一塊未用,便棄在此山青埂 +峰下。誰知此石自經煅煉[3]之後,靈性已通,因見眾石俱得補天,獨自己無材不堪入選,遂自 +怨自嗟,日夜悲號[4]慚愧。 + + 一日,正當嗟悼之餘,俄見一僧一道遠遠而來,生得骨骼不凡,豐神迥异,說說笑笑來至峰 +下,坐於石邊高談快論。先是說些雲山霧海神僊玄幻之事,後便說到紅塵中榮華富貴。此石聽了, +不覺打動凡心,也想要到人間去享一享這榮華富貴,但自恨粗蠢,不得已,便口吐人言,向那僧 +道說道:「大師,弟子蠢物,不能見禮了。適聞二位談那人世間榮耀繁華,心切慕之。弟子質雖 +粗蠢,性卻稍通,況見二師仙形道體,定非凡品,必有補天濟世之材,利物濟人之德。如蒙發一 +點慈心,攜帶弟子得入紅塵,在那富貴場中,溫柔鄉里受享幾年,自當永佩洪恩,萬劫不忘也。」 +二仙師聽畢,齊憨笑道:「善哉,善哉!那紅塵中有卻有些樂事,但不能永遠依恃。況又有美中 +不足、好事多魔八個字緊相連屬,瞬息間則又樂极悲生,人非物換,究竟是到頭一夢,萬境歸空, +倒不如不去的好。」這石凡心已熾,那[5]裡聽得進這話去,乃复苦求再四。二仙知不可強制, +乃歎道:「此亦靜極思動,無中生有之數也。既如此,我們便攜你去受享受享,只是到不得意時, +切莫後悔。」石道:「自然,自然。」那僧又道:「若說你性靈,卻又如此質蠢,并更無奇貴之 +處。如此也只好踮腳而已。也罷,我如今大施佛法助你助,待劫終之日,复還本質,以了此案。 +你道好否?」石頭聽了,感謝不盡。那僧便念咒書符,大展幻術,將一塊大石登時變成一塊鮮明 +瑩洁的美玉,且又縮成扇墜大小的可佩可拿。那僧托於掌上,笑道:「形体倒也是個寶物了!還 +只沒有實在的好處,須得再鐫上數字[6],使人一見便知是奇物方妙。然後攜你到那昌明隆盛之 +邦,詩禮簪纓之族,花錦繁華之地,溫柔富貴之鄉去安身樂業。」石頭聽了,喜不能禁,乃問: +「不知弟子那幾件奇處,又不知携了弟子到何處?望乞明示,使弟子不惑。」那僧笑道:「你且 +莫問,日後自然明白的。」說著,便袖了那石,同那道人飄然而去,竟不知投奔何方何舍。 diff --git a/bin/unit_tests/assets/textformat/chinese.utf8.crlf.nobom.txt b/bin/unit_tests/assets/textformat/chinese.utf8.crlf.nobom.txt new file mode 100644 index 000000000..45eaf879e --- /dev/null +++ b/bin/unit_tests/assets/textformat/chinese.utf8.crlf.nobom.txt @@ -0,0 +1,48 @@ +第一回 甄士隱夢幻識通靈 賈雨村風塵懷閨秀 + + 【甲戌、庚、蒙批:此開卷第一回也。作者自云:因曾歷過一番夢幻之後,故將真事隱去, +而借通靈之說,撰此《石頭記》一書也。故曰「甄士隱夢幻識通靈」。但書中所記何事,又因何 +而撰是書哉?自又云:今風塵碌碌,一事無成,忽念及當日所有之女子,一一細推了去,覺其行 +止見識,皆出於我之上。何我堂堂之鬚眉,曾不若彼裙釵哉!實愧則有餘,悔又無益之大無可奈 +何之日也!當此時,則自欲將已往所賴,上賴天恩,下承祖德,錦衣紈絝之時、飫甘饜美肥之日, +背父母教育之恩,負師兄規訓之德,已至今日一事無成、半生潦倒之罪,編述一記,以告普天下 +人。我之罪固不能免,然閨閣中本自歷歷有人,萬不可因我之不肖,自護其短,則一併使其泯滅 +也。雖今日之茆椽蓬牖,瓦灶繩床,其風晨月夕,階柳庭花,亦未有傷於我之襟懷筆墨者。雖我 +未學,下筆無文,何爲不用假語村言,敷演出一段故事來,以悅人之耳目哉。故曰「風塵懷閨 +秀」,乃是第一回題綱正義也。開卷即曰「風塵懷閨秀」,則知作者本意原爲記述當日閨友閨情, +並非怨世駡時之書矣。雖一時有涉於世態,然亦不得不叙者,但非其本旨耳,閱者切記之。詩曰: + + 【浮生著甚苦奔忙?盛席華筵終散場。】 + 【悲喜千般同幻渺,古今一夢盡荒唐。】 + 【謾言紅袖啼痕重,更有情痴抱恨長。】 + 【字字看來皆是血,十年辛苦不尋常!】 + + 【楊藏、庚辰、夢覺、舒序批:此回中凡用夢用幻等字,是提醒閱者眼目,亦是此書立意本 +旨。】〈按:此兩段回前批语常被混入正文。故雖為批語,仍錄於此。〉 + + 列位看官,你道此書從何而來?說起根由雖近荒唐,細諳則深有趣味。待在下將此來歷注明, +方使聞者了然不惑。 + + 原來,當年女媧氏煉石補天之時,於大荒山無稽崖煉成高經[1]十二丈,方經[2]二十四丈頑 +石三萬六千五百零一塊。媧皇氏只用了三萬六千五百塊,只單單剩了一塊未用,便棄在此山青埂 +峰下。誰知此石自經煅煉[3]之後,靈性已通,因見眾石俱得補天,獨自己無材不堪入選,遂自 +怨自嗟,日夜悲號[4]慚愧。 + + 一日,正當嗟悼之餘,俄見一僧一道遠遠而來,生得骨骼不凡,豐神迥异,說說笑笑來至峰 +下,坐於石邊高談快論。先是說些雲山霧海神僊玄幻之事,後便說到紅塵中榮華富貴。此石聽了, +不覺打動凡心,也想要到人間去享一享這榮華富貴,但自恨粗蠢,不得已,便口吐人言,向那僧 +道說道:「大師,弟子蠢物,不能見禮了。適聞二位談那人世間榮耀繁華,心切慕之。弟子質雖 +粗蠢,性卻稍通,況見二師仙形道體,定非凡品,必有補天濟世之材,利物濟人之德。如蒙發一 +點慈心,攜帶弟子得入紅塵,在那富貴場中,溫柔鄉里受享幾年,自當永佩洪恩,萬劫不忘也。」 +二仙師聽畢,齊憨笑道:「善哉,善哉!那紅塵中有卻有些樂事,但不能永遠依恃。況又有美中 +不足、好事多魔八個字緊相連屬,瞬息間則又樂极悲生,人非物換,究竟是到頭一夢,萬境歸空, +倒不如不去的好。」這石凡心已熾,那[5]裡聽得進這話去,乃复苦求再四。二仙知不可強制, +乃歎道:「此亦靜極思動,無中生有之數也。既如此,我們便攜你去受享受享,只是到不得意時, +切莫後悔。」石道:「自然,自然。」那僧又道:「若說你性靈,卻又如此質蠢,并更無奇貴之 +處。如此也只好踮腳而已。也罷,我如今大施佛法助你助,待劫終之日,复還本質,以了此案。 +你道好否?」石頭聽了,感謝不盡。那僧便念咒書符,大展幻術,將一塊大石登時變成一塊鮮明 +瑩洁的美玉,且又縮成扇墜大小的可佩可拿。那僧托於掌上,笑道:「形体倒也是個寶物了!還 +只沒有實在的好處,須得再鐫上數字[6],使人一見便知是奇物方妙。然後攜你到那昌明隆盛之 +邦,詩禮簪纓之族,花錦繁華之地,溫柔富貴之鄉去安身樂業。」石頭聽了,喜不能禁,乃問: +「不知弟子那幾件奇處,又不知携了弟子到何處?望乞明示,使弟子不惑。」那僧笑道:「你且 +莫問,日後自然明白的。」說著,便袖了那石,同那道人飄然而去,竟不知投奔何方何舍。 diff --git a/bin/unit_tests/assets/textformat/chinese.utf8.lf.bom.txt b/bin/unit_tests/assets/textformat/chinese.utf8.lf.bom.txt new file mode 100644 index 000000000..0c8f72711 --- /dev/null +++ b/bin/unit_tests/assets/textformat/chinese.utf8.lf.bom.txt @@ -0,0 +1,48 @@ +第一回 甄士隱夢幻識通靈 賈雨村風塵懷閨秀 + + 【甲戌、庚、蒙批:此開卷第一回也。作者自云:因曾歷過一番夢幻之後,故將真事隱去, +而借通靈之說,撰此《石頭記》一書也。故曰「甄士隱夢幻識通靈」。但書中所記何事,又因何 +而撰是書哉?自又云:今風塵碌碌,一事無成,忽念及當日所有之女子,一一細推了去,覺其行 +止見識,皆出於我之上。何我堂堂之鬚眉,曾不若彼裙釵哉!實愧則有餘,悔又無益之大無可奈 +何之日也!當此時,則自欲將已往所賴,上賴天恩,下承祖德,錦衣紈絝之時、飫甘饜美肥之日, +背父母教育之恩,負師兄規訓之德,已至今日一事無成、半生潦倒之罪,編述一記,以告普天下 +人。我之罪固不能免,然閨閣中本自歷歷有人,萬不可因我之不肖,自護其短,則一併使其泯滅 +也。雖今日之茆椽蓬牖,瓦灶繩床,其風晨月夕,階柳庭花,亦未有傷於我之襟懷筆墨者。雖我 +未學,下筆無文,何爲不用假語村言,敷演出一段故事來,以悅人之耳目哉。故曰「風塵懷閨 +秀」,乃是第一回題綱正義也。開卷即曰「風塵懷閨秀」,則知作者本意原爲記述當日閨友閨情, +並非怨世駡時之書矣。雖一時有涉於世態,然亦不得不叙者,但非其本旨耳,閱者切記之。詩曰: + + 【浮生著甚苦奔忙?盛席華筵終散場。】 + 【悲喜千般同幻渺,古今一夢盡荒唐。】 + 【謾言紅袖啼痕重,更有情痴抱恨長。】 + 【字字看來皆是血,十年辛苦不尋常!】 + + 【楊藏、庚辰、夢覺、舒序批:此回中凡用夢用幻等字,是提醒閱者眼目,亦是此書立意本 +旨。】〈按:此兩段回前批语常被混入正文。故雖為批語,仍錄於此。〉 + + 列位看官,你道此書從何而來?說起根由雖近荒唐,細諳則深有趣味。待在下將此來歷注明, +方使聞者了然不惑。 + + 原來,當年女媧氏煉石補天之時,於大荒山無稽崖煉成高經[1]十二丈,方經[2]二十四丈頑 +石三萬六千五百零一塊。媧皇氏只用了三萬六千五百塊,只單單剩了一塊未用,便棄在此山青埂 +峰下。誰知此石自經煅煉[3]之後,靈性已通,因見眾石俱得補天,獨自己無材不堪入選,遂自 +怨自嗟,日夜悲號[4]慚愧。 + + 一日,正當嗟悼之餘,俄見一僧一道遠遠而來,生得骨骼不凡,豐神迥异,說說笑笑來至峰 +下,坐於石邊高談快論。先是說些雲山霧海神僊玄幻之事,後便說到紅塵中榮華富貴。此石聽了, +不覺打動凡心,也想要到人間去享一享這榮華富貴,但自恨粗蠢,不得已,便口吐人言,向那僧 +道說道:「大師,弟子蠢物,不能見禮了。適聞二位談那人世間榮耀繁華,心切慕之。弟子質雖 +粗蠢,性卻稍通,況見二師仙形道體,定非凡品,必有補天濟世之材,利物濟人之德。如蒙發一 +點慈心,攜帶弟子得入紅塵,在那富貴場中,溫柔鄉里受享幾年,自當永佩洪恩,萬劫不忘也。」 +二仙師聽畢,齊憨笑道:「善哉,善哉!那紅塵中有卻有些樂事,但不能永遠依恃。況又有美中 +不足、好事多魔八個字緊相連屬,瞬息間則又樂极悲生,人非物換,究竟是到頭一夢,萬境歸空, +倒不如不去的好。」這石凡心已熾,那[5]裡聽得進這話去,乃复苦求再四。二仙知不可強制, +乃歎道:「此亦靜極思動,無中生有之數也。既如此,我們便攜你去受享受享,只是到不得意時, +切莫後悔。」石道:「自然,自然。」那僧又道:「若說你性靈,卻又如此質蠢,并更無奇貴之 +處。如此也只好踮腳而已。也罷,我如今大施佛法助你助,待劫終之日,复還本質,以了此案。 +你道好否?」石頭聽了,感謝不盡。那僧便念咒書符,大展幻術,將一塊大石登時變成一塊鮮明 +瑩洁的美玉,且又縮成扇墜大小的可佩可拿。那僧托於掌上,笑道:「形体倒也是個寶物了!還 +只沒有實在的好處,須得再鐫上數字[6],使人一見便知是奇物方妙。然後攜你到那昌明隆盛之 +邦,詩禮簪纓之族,花錦繁華之地,溫柔富貴之鄉去安身樂業。」石頭聽了,喜不能禁,乃問: +「不知弟子那幾件奇處,又不知携了弟子到何處?望乞明示,使弟子不惑。」那僧笑道:「你且 +莫問,日後自然明白的。」說著,便袖了那石,同那道人飄然而去,竟不知投奔何方何舍。 diff --git a/bin/unit_tests/assets/textformat/chinese.utf8.lf.nobom.txt b/bin/unit_tests/assets/textformat/chinese.utf8.lf.nobom.txt new file mode 100644 index 000000000..1da0a5424 --- /dev/null +++ b/bin/unit_tests/assets/textformat/chinese.utf8.lf.nobom.txt @@ -0,0 +1,48 @@ +第一回 甄士隱夢幻識通靈 賈雨村風塵懷閨秀 + + 【甲戌、庚、蒙批:此開卷第一回也。作者自云:因曾歷過一番夢幻之後,故將真事隱去, +而借通靈之說,撰此《石頭記》一書也。故曰「甄士隱夢幻識通靈」。但書中所記何事,又因何 +而撰是書哉?自又云:今風塵碌碌,一事無成,忽念及當日所有之女子,一一細推了去,覺其行 +止見識,皆出於我之上。何我堂堂之鬚眉,曾不若彼裙釵哉!實愧則有餘,悔又無益之大無可奈 +何之日也!當此時,則自欲將已往所賴,上賴天恩,下承祖德,錦衣紈絝之時、飫甘饜美肥之日, +背父母教育之恩,負師兄規訓之德,已至今日一事無成、半生潦倒之罪,編述一記,以告普天下 +人。我之罪固不能免,然閨閣中本自歷歷有人,萬不可因我之不肖,自護其短,則一併使其泯滅 +也。雖今日之茆椽蓬牖,瓦灶繩床,其風晨月夕,階柳庭花,亦未有傷於我之襟懷筆墨者。雖我 +未學,下筆無文,何爲不用假語村言,敷演出一段故事來,以悅人之耳目哉。故曰「風塵懷閨 +秀」,乃是第一回題綱正義也。開卷即曰「風塵懷閨秀」,則知作者本意原爲記述當日閨友閨情, +並非怨世駡時之書矣。雖一時有涉於世態,然亦不得不叙者,但非其本旨耳,閱者切記之。詩曰: + + 【浮生著甚苦奔忙?盛席華筵終散場。】 + 【悲喜千般同幻渺,古今一夢盡荒唐。】 + 【謾言紅袖啼痕重,更有情痴抱恨長。】 + 【字字看來皆是血,十年辛苦不尋常!】 + + 【楊藏、庚辰、夢覺、舒序批:此回中凡用夢用幻等字,是提醒閱者眼目,亦是此書立意本 +旨。】〈按:此兩段回前批语常被混入正文。故雖為批語,仍錄於此。〉 + + 列位看官,你道此書從何而來?說起根由雖近荒唐,細諳則深有趣味。待在下將此來歷注明, +方使聞者了然不惑。 + + 原來,當年女媧氏煉石補天之時,於大荒山無稽崖煉成高經[1]十二丈,方經[2]二十四丈頑 +石三萬六千五百零一塊。媧皇氏只用了三萬六千五百塊,只單單剩了一塊未用,便棄在此山青埂 +峰下。誰知此石自經煅煉[3]之後,靈性已通,因見眾石俱得補天,獨自己無材不堪入選,遂自 +怨自嗟,日夜悲號[4]慚愧。 + + 一日,正當嗟悼之餘,俄見一僧一道遠遠而來,生得骨骼不凡,豐神迥异,說說笑笑來至峰 +下,坐於石邊高談快論。先是說些雲山霧海神僊玄幻之事,後便說到紅塵中榮華富貴。此石聽了, +不覺打動凡心,也想要到人間去享一享這榮華富貴,但自恨粗蠢,不得已,便口吐人言,向那僧 +道說道:「大師,弟子蠢物,不能見禮了。適聞二位談那人世間榮耀繁華,心切慕之。弟子質雖 +粗蠢,性卻稍通,況見二師仙形道體,定非凡品,必有補天濟世之材,利物濟人之德。如蒙發一 +點慈心,攜帶弟子得入紅塵,在那富貴場中,溫柔鄉里受享幾年,自當永佩洪恩,萬劫不忘也。」 +二仙師聽畢,齊憨笑道:「善哉,善哉!那紅塵中有卻有些樂事,但不能永遠依恃。況又有美中 +不足、好事多魔八個字緊相連屬,瞬息間則又樂极悲生,人非物換,究竟是到頭一夢,萬境歸空, +倒不如不去的好。」這石凡心已熾,那[5]裡聽得進這話去,乃复苦求再四。二仙知不可強制, +乃歎道:「此亦靜極思動,無中生有之數也。既如此,我們便攜你去受享受享,只是到不得意時, +切莫後悔。」石道:「自然,自然。」那僧又道:「若說你性靈,卻又如此質蠢,并更無奇貴之 +處。如此也只好踮腳而已。也罷,我如今大施佛法助你助,待劫終之日,复還本質,以了此案。 +你道好否?」石頭聽了,感謝不盡。那僧便念咒書符,大展幻術,將一塊大石登時變成一塊鮮明 +瑩洁的美玉,且又縮成扇墜大小的可佩可拿。那僧托於掌上,笑道:「形体倒也是個寶物了!還 +只沒有實在的好處,須得再鐫上數字[6],使人一見便知是奇物方妙。然後攜你到那昌明隆盛之 +邦,詩禮簪纓之族,花錦繁華之地,溫柔富貴之鄉去安身樂業。」石頭聽了,喜不能禁,乃問: +「不知弟子那幾件奇處,又不知携了弟子到何處?望乞明示,使弟子不惑。」那僧笑道:「你且 +莫問,日後自然明白的。」說著,便袖了那石,同那道人飄然而去,竟不知投奔何方何舍。 diff --git a/bin/unit_tests/assets/textformat/english.utf16be.crlf.bom.txt b/bin/unit_tests/assets/textformat/english.utf16be.crlf.bom.txt new file mode 100644 index 000000000..d35d6189d Binary files /dev/null and b/bin/unit_tests/assets/textformat/english.utf16be.crlf.bom.txt differ diff --git a/bin/unit_tests/assets/textformat/english.utf16be.crlf.nobom.txt b/bin/unit_tests/assets/textformat/english.utf16be.crlf.nobom.txt new file mode 100644 index 000000000..554fe302b Binary files /dev/null and b/bin/unit_tests/assets/textformat/english.utf16be.crlf.nobom.txt differ diff --git a/bin/unit_tests/assets/textformat/english.utf16be.lf.bom.txt b/bin/unit_tests/assets/textformat/english.utf16be.lf.bom.txt new file mode 100644 index 000000000..7dfa385e0 Binary files /dev/null and b/bin/unit_tests/assets/textformat/english.utf16be.lf.bom.txt differ diff --git a/bin/unit_tests/assets/textformat/english.utf16be.lf.nobom.txt b/bin/unit_tests/assets/textformat/english.utf16be.lf.nobom.txt new file mode 100644 index 000000000..82bc2af33 Binary files /dev/null and b/bin/unit_tests/assets/textformat/english.utf16be.lf.nobom.txt differ diff --git a/bin/unit_tests/assets/textformat/english.utf16le.crlf.bom.txt b/bin/unit_tests/assets/textformat/english.utf16le.crlf.bom.txt new file mode 100644 index 000000000..62ac60290 Binary files /dev/null and b/bin/unit_tests/assets/textformat/english.utf16le.crlf.bom.txt differ diff --git a/bin/unit_tests/assets/textformat/english.utf16le.crlf.nobom.txt b/bin/unit_tests/assets/textformat/english.utf16le.crlf.nobom.txt new file mode 100644 index 000000000..64092e18e Binary files /dev/null and b/bin/unit_tests/assets/textformat/english.utf16le.crlf.nobom.txt differ diff --git a/bin/unit_tests/assets/textformat/english.utf16le.lf.bom.txt b/bin/unit_tests/assets/textformat/english.utf16le.lf.bom.txt new file mode 100644 index 000000000..70737cea6 Binary files /dev/null and b/bin/unit_tests/assets/textformat/english.utf16le.lf.bom.txt differ diff --git a/bin/unit_tests/assets/textformat/english.utf16le.lf.nobom.txt b/bin/unit_tests/assets/textformat/english.utf16le.lf.nobom.txt new file mode 100644 index 000000000..c522e2981 Binary files /dev/null and b/bin/unit_tests/assets/textformat/english.utf16le.lf.nobom.txt differ diff --git a/bin/unit_tests/assets/textformat/english.utf8.crlf.bom.txt b/bin/unit_tests/assets/textformat/english.utf8.crlf.bom.txt new file mode 100644 index 000000000..586cff94b --- /dev/null +++ b/bin/unit_tests/assets/textformat/english.utf8.crlf.bom.txt @@ -0,0 +1,60 @@ +It was a bright cold day in April, and the clocks were striking thirteen. +Winston Smith, his chin nuzzled into his breast in an effort to escape the +vile wind, slipped quickly through the glass doors of Victory Mansions, +though not quickly enough to prevent a swirl of gritty dust from entering +along with him. + +The hallway smelt of boiled cabbage and old rag mats. At one end of it a +coloured poster, too large for indoor display, had been tacked to the wall. +It depicted simply an enormous face, more than a metre wide: the face of a +man of about forty-five, with a heavy black moustache and ruggedly handsome +features. Winston made for the stairs. It was no use trying the lift. Even +at the best of times it was seldom working, and at present the electric +current was cut off during daylight hours. It was part of the economy drive +in preparation for Hate Week. The flat was seven flights up, and Winston, +who was thirty-nine and had a varicose ulcer above his right ankle, went +slowly, resting several times on the way. On each landing, opposite the +lift-shaft, the poster with the enormous face gazed from the wall. It was +one of those pictures which are so contrived that the eyes follow you about +when you move. BIG BROTHER IS WATCHING YOU, the caption beneath it ran. + +Inside the flat a fruity voice was reading out a list of figures which had +something to do with the production of pig-iron. The voice came from an +oblong metal plaque like a dulled mirror which formed part of the surface +of the right-hand wall. Winston turned a switch and the voice sank +somewhat, though the words were still distinguishable. The instrument +(the telescreen, it was called) could be dimmed, but there was no way of +shutting it off completely. He moved over to the window: a smallish, frail +figure, the meagreness of his body merely emphasized by the blue overalls +which were the uniform of the party. His hair was very fair, his face +naturally sanguine, his skin roughened by coarse soap and blunt razor +blades and the cold of the winter that had just ended. + +Outside, even through the shut window-pane, the world looked cold. Down in +the street little eddies of wind were whirling dust and torn paper into +spirals, and though the sun was shining and the sky a harsh blue, there +seemed to be no colour in anything, except the posters that were plastered +everywhere. The black-moustachio'd face gazed down from every commanding +corner. There was one on the house-front immediately opposite. BIG BROTHER +IS WATCHING YOU, the caption said, while the dark eyes looked deep into +Winston's own. Down at street level another poster, torn at one corner, +flapped fitfully in the wind, alternately covering and uncovering the +single word INGSOC. In the far distance a helicopter skimmed down between +the roofs, hovered for an instant like a bluebottle, and darted away again +with a curving flight. It was the police patrol, snooping into people's +windows. The patrols did not matter, however. Only the Thought Police +mattered. + +Behind Winston's back the voice from the telescreen was still babbling away +about pig-iron and the overfulfilment of the Ninth Three-Year Plan. The +telescreen received and transmitted simultaneously. Any sound that Winston +made, above the level of a very low whisper, would be picked up by it, +moreover, so long as he remained within the field of vision which the metal +plaque commanded, he could be seen as well as heard. There was of course +no way of knowing whether you were being watched at any given moment. How +often, or on what system, the Thought Police plugged in on any individual +wire was guesswork. It was even conceivable that they watched everybody all +the time. But at any rate they could plug in your wire whenever they wanted +to. You had to live--did live, from habit that became instinct--in the +assumption that every sound you made was overheard, and, except in +darkness, every movement scrutinized. diff --git a/bin/unit_tests/assets/textformat/english.utf8.crlf.nobom.txt b/bin/unit_tests/assets/textformat/english.utf8.crlf.nobom.txt new file mode 100644 index 000000000..fae949ade --- /dev/null +++ b/bin/unit_tests/assets/textformat/english.utf8.crlf.nobom.txt @@ -0,0 +1,60 @@ +It was a bright cold day in April, and the clocks were striking thirteen. +Winston Smith, his chin nuzzled into his breast in an effort to escape the +vile wind, slipped quickly through the glass doors of Victory Mansions, +though not quickly enough to prevent a swirl of gritty dust from entering +along with him. + +The hallway smelt of boiled cabbage and old rag mats. At one end of it a +coloured poster, too large for indoor display, had been tacked to the wall. +It depicted simply an enormous face, more than a metre wide: the face of a +man of about forty-five, with a heavy black moustache and ruggedly handsome +features. Winston made for the stairs. It was no use trying the lift. Even +at the best of times it was seldom working, and at present the electric +current was cut off during daylight hours. It was part of the economy drive +in preparation for Hate Week. The flat was seven flights up, and Winston, +who was thirty-nine and had a varicose ulcer above his right ankle, went +slowly, resting several times on the way. On each landing, opposite the +lift-shaft, the poster with the enormous face gazed from the wall. It was +one of those pictures which are so contrived that the eyes follow you about +when you move. BIG BROTHER IS WATCHING YOU, the caption beneath it ran. + +Inside the flat a fruity voice was reading out a list of figures which had +something to do with the production of pig-iron. The voice came from an +oblong metal plaque like a dulled mirror which formed part of the surface +of the right-hand wall. Winston turned a switch and the voice sank +somewhat, though the words were still distinguishable. The instrument +(the telescreen, it was called) could be dimmed, but there was no way of +shutting it off completely. He moved over to the window: a smallish, frail +figure, the meagreness of his body merely emphasized by the blue overalls +which were the uniform of the party. His hair was very fair, his face +naturally sanguine, his skin roughened by coarse soap and blunt razor +blades and the cold of the winter that had just ended. + +Outside, even through the shut window-pane, the world looked cold. Down in +the street little eddies of wind were whirling dust and torn paper into +spirals, and though the sun was shining and the sky a harsh blue, there +seemed to be no colour in anything, except the posters that were plastered +everywhere. The black-moustachio'd face gazed down from every commanding +corner. There was one on the house-front immediately opposite. BIG BROTHER +IS WATCHING YOU, the caption said, while the dark eyes looked deep into +Winston's own. Down at street level another poster, torn at one corner, +flapped fitfully in the wind, alternately covering and uncovering the +single word INGSOC. In the far distance a helicopter skimmed down between +the roofs, hovered for an instant like a bluebottle, and darted away again +with a curving flight. It was the police patrol, snooping into people's +windows. The patrols did not matter, however. Only the Thought Police +mattered. + +Behind Winston's back the voice from the telescreen was still babbling away +about pig-iron and the overfulfilment of the Ninth Three-Year Plan. The +telescreen received and transmitted simultaneously. Any sound that Winston +made, above the level of a very low whisper, would be picked up by it, +moreover, so long as he remained within the field of vision which the metal +plaque commanded, he could be seen as well as heard. There was of course +no way of knowing whether you were being watched at any given moment. How +often, or on what system, the Thought Police plugged in on any individual +wire was guesswork. It was even conceivable that they watched everybody all +the time. But at any rate they could plug in your wire whenever they wanted +to. You had to live--did live, from habit that became instinct--in the +assumption that every sound you made was overheard, and, except in +darkness, every movement scrutinized. diff --git a/bin/unit_tests/assets/textformat/english.utf8.lf.bom.txt b/bin/unit_tests/assets/textformat/english.utf8.lf.bom.txt new file mode 100644 index 000000000..3a341f83d --- /dev/null +++ b/bin/unit_tests/assets/textformat/english.utf8.lf.bom.txt @@ -0,0 +1,60 @@ +It was a bright cold day in April, and the clocks were striking thirteen. +Winston Smith, his chin nuzzled into his breast in an effort to escape the +vile wind, slipped quickly through the glass doors of Victory Mansions, +though not quickly enough to prevent a swirl of gritty dust from entering +along with him. + +The hallway smelt of boiled cabbage and old rag mats. At one end of it a +coloured poster, too large for indoor display, had been tacked to the wall. +It depicted simply an enormous face, more than a metre wide: the face of a +man of about forty-five, with a heavy black moustache and ruggedly handsome +features. Winston made for the stairs. It was no use trying the lift. Even +at the best of times it was seldom working, and at present the electric +current was cut off during daylight hours. It was part of the economy drive +in preparation for Hate Week. The flat was seven flights up, and Winston, +who was thirty-nine and had a varicose ulcer above his right ankle, went +slowly, resting several times on the way. On each landing, opposite the +lift-shaft, the poster with the enormous face gazed from the wall. It was +one of those pictures which are so contrived that the eyes follow you about +when you move. BIG BROTHER IS WATCHING YOU, the caption beneath it ran. + +Inside the flat a fruity voice was reading out a list of figures which had +something to do with the production of pig-iron. The voice came from an +oblong metal plaque like a dulled mirror which formed part of the surface +of the right-hand wall. Winston turned a switch and the voice sank +somewhat, though the words were still distinguishable. The instrument +(the telescreen, it was called) could be dimmed, but there was no way of +shutting it off completely. He moved over to the window: a smallish, frail +figure, the meagreness of his body merely emphasized by the blue overalls +which were the uniform of the party. His hair was very fair, his face +naturally sanguine, his skin roughened by coarse soap and blunt razor +blades and the cold of the winter that had just ended. + +Outside, even through the shut window-pane, the world looked cold. Down in +the street little eddies of wind were whirling dust and torn paper into +spirals, and though the sun was shining and the sky a harsh blue, there +seemed to be no colour in anything, except the posters that were plastered +everywhere. The black-moustachio'd face gazed down from every commanding +corner. There was one on the house-front immediately opposite. BIG BROTHER +IS WATCHING YOU, the caption said, while the dark eyes looked deep into +Winston's own. Down at street level another poster, torn at one corner, +flapped fitfully in the wind, alternately covering and uncovering the +single word INGSOC. In the far distance a helicopter skimmed down between +the roofs, hovered for an instant like a bluebottle, and darted away again +with a curving flight. It was the police patrol, snooping into people's +windows. The patrols did not matter, however. Only the Thought Police +mattered. + +Behind Winston's back the voice from the telescreen was still babbling away +about pig-iron and the overfulfilment of the Ninth Three-Year Plan. The +telescreen received and transmitted simultaneously. Any sound that Winston +made, above the level of a very low whisper, would be picked up by it, +moreover, so long as he remained within the field of vision which the metal +plaque commanded, he could be seen as well as heard. There was of course +no way of knowing whether you were being watched at any given moment. How +often, or on what system, the Thought Police plugged in on any individual +wire was guesswork. It was even conceivable that they watched everybody all +the time. But at any rate they could plug in your wire whenever they wanted +to. You had to live--did live, from habit that became instinct--in the +assumption that every sound you made was overheard, and, except in +darkness, every movement scrutinized. diff --git a/bin/unit_tests/assets/textformat/english.utf8.lf.nobom.txt b/bin/unit_tests/assets/textformat/english.utf8.lf.nobom.txt new file mode 100644 index 000000000..8546d9f00 --- /dev/null +++ b/bin/unit_tests/assets/textformat/english.utf8.lf.nobom.txt @@ -0,0 +1,60 @@ +It was a bright cold day in April, and the clocks were striking thirteen. +Winston Smith, his chin nuzzled into his breast in an effort to escape the +vile wind, slipped quickly through the glass doors of Victory Mansions, +though not quickly enough to prevent a swirl of gritty dust from entering +along with him. + +The hallway smelt of boiled cabbage and old rag mats. At one end of it a +coloured poster, too large for indoor display, had been tacked to the wall. +It depicted simply an enormous face, more than a metre wide: the face of a +man of about forty-five, with a heavy black moustache and ruggedly handsome +features. Winston made for the stairs. It was no use trying the lift. Even +at the best of times it was seldom working, and at present the electric +current was cut off during daylight hours. It was part of the economy drive +in preparation for Hate Week. The flat was seven flights up, and Winston, +who was thirty-nine and had a varicose ulcer above his right ankle, went +slowly, resting several times on the way. On each landing, opposite the +lift-shaft, the poster with the enormous face gazed from the wall. It was +one of those pictures which are so contrived that the eyes follow you about +when you move. BIG BROTHER IS WATCHING YOU, the caption beneath it ran. + +Inside the flat a fruity voice was reading out a list of figures which had +something to do with the production of pig-iron. The voice came from an +oblong metal plaque like a dulled mirror which formed part of the surface +of the right-hand wall. Winston turned a switch and the voice sank +somewhat, though the words were still distinguishable. The instrument +(the telescreen, it was called) could be dimmed, but there was no way of +shutting it off completely. He moved over to the window: a smallish, frail +figure, the meagreness of his body merely emphasized by the blue overalls +which were the uniform of the party. His hair was very fair, his face +naturally sanguine, his skin roughened by coarse soap and blunt razor +blades and the cold of the winter that had just ended. + +Outside, even through the shut window-pane, the world looked cold. Down in +the street little eddies of wind were whirling dust and torn paper into +spirals, and though the sun was shining and the sky a harsh blue, there +seemed to be no colour in anything, except the posters that were plastered +everywhere. The black-moustachio'd face gazed down from every commanding +corner. There was one on the house-front immediately opposite. BIG BROTHER +IS WATCHING YOU, the caption said, while the dark eyes looked deep into +Winston's own. Down at street level another poster, torn at one corner, +flapped fitfully in the wind, alternately covering and uncovering the +single word INGSOC. In the far distance a helicopter skimmed down between +the roofs, hovered for an instant like a bluebottle, and darted away again +with a curving flight. It was the police patrol, snooping into people's +windows. The patrols did not matter, however. Only the Thought Police +mattered. + +Behind Winston's back the voice from the telescreen was still babbling away +about pig-iron and the overfulfilment of the Ninth Three-Year Plan. The +telescreen received and transmitted simultaneously. Any sound that Winston +made, above the level of a very low whisper, would be picked up by it, +moreover, so long as he remained within the field of vision which the metal +plaque commanded, he could be seen as well as heard. There was of course +no way of knowing whether you were being watched at any given moment. How +often, or on what system, the Thought Police plugged in on any individual +wire was guesswork. It was even conceivable that they watched everybody all +the time. But at any rate they could plug in your wire whenever they wanted +to. You had to live--did live, from habit that became instinct--in the +assumption that every sound you made was overheard, and, except in +darkness, every movement scrutinized. diff --git a/bin/unit_tests/assets/textformat/french.utf16be.crlf.bom.txt b/bin/unit_tests/assets/textformat/french.utf16be.crlf.bom.txt new file mode 100644 index 000000000..0aa6bc99e Binary files /dev/null and b/bin/unit_tests/assets/textformat/french.utf16be.crlf.bom.txt differ diff --git a/bin/unit_tests/assets/textformat/french.utf16be.crlf.nobom.txt b/bin/unit_tests/assets/textformat/french.utf16be.crlf.nobom.txt new file mode 100644 index 000000000..10bd46704 Binary files /dev/null and b/bin/unit_tests/assets/textformat/french.utf16be.crlf.nobom.txt differ diff --git a/bin/unit_tests/assets/textformat/french.utf16be.lf.bom.txt b/bin/unit_tests/assets/textformat/french.utf16be.lf.bom.txt new file mode 100644 index 000000000..ffff48dd3 Binary files /dev/null and b/bin/unit_tests/assets/textformat/french.utf16be.lf.bom.txt differ diff --git a/bin/unit_tests/assets/textformat/french.utf16be.lf.nobom.txt b/bin/unit_tests/assets/textformat/french.utf16be.lf.nobom.txt new file mode 100644 index 000000000..0fe3d5207 Binary files /dev/null and b/bin/unit_tests/assets/textformat/french.utf16be.lf.nobom.txt differ diff --git a/bin/unit_tests/assets/textformat/french.utf16le.crlf.bom.txt b/bin/unit_tests/assets/textformat/french.utf16le.crlf.bom.txt new file mode 100644 index 000000000..fdc52d8d4 Binary files /dev/null and b/bin/unit_tests/assets/textformat/french.utf16le.crlf.bom.txt differ diff --git a/bin/unit_tests/assets/textformat/french.utf16le.crlf.nobom.txt b/bin/unit_tests/assets/textformat/french.utf16le.crlf.nobom.txt new file mode 100644 index 000000000..8cb1ab734 Binary files /dev/null and b/bin/unit_tests/assets/textformat/french.utf16le.crlf.nobom.txt differ diff --git a/bin/unit_tests/assets/textformat/french.utf16le.lf.bom.txt b/bin/unit_tests/assets/textformat/french.utf16le.lf.bom.txt new file mode 100644 index 000000000..a5b5abbf3 Binary files /dev/null and b/bin/unit_tests/assets/textformat/french.utf16le.lf.bom.txt differ diff --git a/bin/unit_tests/assets/textformat/french.utf16le.lf.nobom.txt b/bin/unit_tests/assets/textformat/french.utf16le.lf.nobom.txt new file mode 100644 index 000000000..1a06686ac Binary files /dev/null and b/bin/unit_tests/assets/textformat/french.utf16le.lf.nobom.txt differ diff --git a/bin/unit_tests/assets/textformat/french.utf8.crlf.bom.txt b/bin/unit_tests/assets/textformat/french.utf8.crlf.bom.txt new file mode 100644 index 000000000..d89e2a742 --- /dev/null +++ b/bin/unit_tests/assets/textformat/french.utf8.crlf.bom.txt @@ -0,0 +1,66 @@ +En 1815, M. Charles-François-Bienvenu Myriel était évêque de Digne. +C'était un vieillard d'environ soixante-quinze ans; il occupait le siège +de Digne depuis 1806. + +Quoique ce détail ne touche en aucune manière au fond même de ce que +nous avons à raconter, il n'est peut-être pas inutile, ne fût-ce que +pour être exact en tout, d'indiquer ici les bruits et les propos qui +avaient couru sur son compte au moment où il était arrivé dans le +diocèse. Vrai ou faux, ce qu'on dit des hommes tient souvent autant de +place dans leur vie et surtout dans leur destinée que ce qu'ils font. M. +Myriel était fils d'un conseiller au parlement d'Aix; noblesse de robe. +On contait de lui que son père, le réservant pour hériter de sa charge, +l'avait marié de fort bonne heure, à dix-huit ou vingt ans, suivant un +usage assez répandu dans les familles parlementaires. Charles Myriel, +nonobstant ce mariage, avait, disait-on, beaucoup fait parler de lui. Il +était bien fait de sa personne, quoique d'assez petite taille, élégant, +gracieux, spirituel; toute la première partie de sa vie avait été donnée +au monde et aux galanteries. La révolution survint, les événements se +précipitèrent, les familles parlementaires décimées, chassées, traquées, +se dispersèrent. M. Charles Myriel, dès les premiers jours de la +révolution, émigra en Italie. Sa femme y mourut d'une maladie de +poitrine dont elle était atteinte depuis longtemps. Ils n'avaient point +d'enfants. Que se passa-t-il ensuite dans la destinée de M. Myriel? +L'écroulement de l'ancienne société française, la chute de sa propre +famille, les tragiques spectacles de 93, plus effrayants encore +peut-être pour les émigrés qui les voyaient de loin avec le +grossissement de l'épouvante, firent-ils germer en lui des idées de +renoncement et de solitude? Fut-il, au milieu d'une de ces distractions +et de ces affections qui occupaient sa vie, subitement atteint d'un de +ces coups mystérieux et terribles qui viennent quelquefois renverser, en +le frappant au coeur, l'homme que les catastrophes publiques +n'ébranleraient pas en le frappant dans son existence et dans sa +fortune? Nul n'aurait pu le dire; tout ce qu'on savait, c'est que, +lorsqu'il revint d'Italie, il était prêtre. + +En 1804, M. Myriel était curé de Brignolles. Il était déjà vieux, et +vivait dans une retraite profonde. + +Vers l'époque du couronnement, une petite affaire de sa cure, on ne sait +plus trop quoi, l'amena à Paris. Entre autres personnes puissantes, il +alla solliciter pour ses paroissiens M. le cardinal Fesch. Un jour que +l'empereur était venu faire visite à son oncle, le digne curé, qui +attendait dans l'antichambre, se trouva sur le passage de sa majesté. +Napoléon, se voyant regardé avec une certaine curiosité par ce +vieillard, se retourna, et dit brusquement: + +--Quel est ce bonhomme qui me regarde? + +--Sire, dit M. Myriel, vous regardez un bonhomme, et moi je regarde un +grand homme. Chacun de nous peut profiter. + +L'empereur, le soir même, demanda au cardinal le nom de ce curé, et +quelque temps après M. Myriel fut tout surpris d'apprendre qu'il était +nommé évêque de Digne. + +Qu'y avait-il de vrai, du reste, dans les récits qu'on faisait sur la +première partie de la vie de M. Myriel? Personne ne le savait. Peu de +familles avaient connu la famille Myriel avant la révolution. + +M. Myriel devait subir le sort de tout nouveau venu dans une petite +ville où il y a beaucoup de bouches qui parlent et fort peu de têtes qui +pensent. Il devait le subir, quoiqu'il fût évêque et parce qu'il était +évêque. Mais, après tout, les propos auxquels on mêlait son nom +n'étaient peut-être que des propos; du bruit, des mots, des paroles; +moins que des paroles, des _palabres_, comme dit l'énergique langue du +midi. diff --git a/bin/unit_tests/assets/textformat/french.utf8.crlf.nobom.txt b/bin/unit_tests/assets/textformat/french.utf8.crlf.nobom.txt new file mode 100644 index 000000000..1f836cf72 --- /dev/null +++ b/bin/unit_tests/assets/textformat/french.utf8.crlf.nobom.txt @@ -0,0 +1,66 @@ +En 1815, M. Charles-François-Bienvenu Myriel était évêque de Digne. +C'était un vieillard d'environ soixante-quinze ans; il occupait le siège +de Digne depuis 1806. + +Quoique ce détail ne touche en aucune manière au fond même de ce que +nous avons à raconter, il n'est peut-être pas inutile, ne fût-ce que +pour être exact en tout, d'indiquer ici les bruits et les propos qui +avaient couru sur son compte au moment où il était arrivé dans le +diocèse. Vrai ou faux, ce qu'on dit des hommes tient souvent autant de +place dans leur vie et surtout dans leur destinée que ce qu'ils font. M. +Myriel était fils d'un conseiller au parlement d'Aix; noblesse de robe. +On contait de lui que son père, le réservant pour hériter de sa charge, +l'avait marié de fort bonne heure, à dix-huit ou vingt ans, suivant un +usage assez répandu dans les familles parlementaires. Charles Myriel, +nonobstant ce mariage, avait, disait-on, beaucoup fait parler de lui. Il +était bien fait de sa personne, quoique d'assez petite taille, élégant, +gracieux, spirituel; toute la première partie de sa vie avait été donnée +au monde et aux galanteries. La révolution survint, les événements se +précipitèrent, les familles parlementaires décimées, chassées, traquées, +se dispersèrent. M. Charles Myriel, dès les premiers jours de la +révolution, émigra en Italie. Sa femme y mourut d'une maladie de +poitrine dont elle était atteinte depuis longtemps. Ils n'avaient point +d'enfants. Que se passa-t-il ensuite dans la destinée de M. Myriel? +L'écroulement de l'ancienne société française, la chute de sa propre +famille, les tragiques spectacles de 93, plus effrayants encore +peut-être pour les émigrés qui les voyaient de loin avec le +grossissement de l'épouvante, firent-ils germer en lui des idées de +renoncement et de solitude? Fut-il, au milieu d'une de ces distractions +et de ces affections qui occupaient sa vie, subitement atteint d'un de +ces coups mystérieux et terribles qui viennent quelquefois renverser, en +le frappant au coeur, l'homme que les catastrophes publiques +n'ébranleraient pas en le frappant dans son existence et dans sa +fortune? Nul n'aurait pu le dire; tout ce qu'on savait, c'est que, +lorsqu'il revint d'Italie, il était prêtre. + +En 1804, M. Myriel était curé de Brignolles. Il était déjà vieux, et +vivait dans une retraite profonde. + +Vers l'époque du couronnement, une petite affaire de sa cure, on ne sait +plus trop quoi, l'amena à Paris. Entre autres personnes puissantes, il +alla solliciter pour ses paroissiens M. le cardinal Fesch. Un jour que +l'empereur était venu faire visite à son oncle, le digne curé, qui +attendait dans l'antichambre, se trouva sur le passage de sa majesté. +Napoléon, se voyant regardé avec une certaine curiosité par ce +vieillard, se retourna, et dit brusquement: + +--Quel est ce bonhomme qui me regarde? + +--Sire, dit M. Myriel, vous regardez un bonhomme, et moi je regarde un +grand homme. Chacun de nous peut profiter. + +L'empereur, le soir même, demanda au cardinal le nom de ce curé, et +quelque temps après M. Myriel fut tout surpris d'apprendre qu'il était +nommé évêque de Digne. + +Qu'y avait-il de vrai, du reste, dans les récits qu'on faisait sur la +première partie de la vie de M. Myriel? Personne ne le savait. Peu de +familles avaient connu la famille Myriel avant la révolution. + +M. Myriel devait subir le sort de tout nouveau venu dans une petite +ville où il y a beaucoup de bouches qui parlent et fort peu de têtes qui +pensent. Il devait le subir, quoiqu'il fût évêque et parce qu'il était +évêque. Mais, après tout, les propos auxquels on mêlait son nom +n'étaient peut-être que des propos; du bruit, des mots, des paroles; +moins que des paroles, des _palabres_, comme dit l'énergique langue du +midi. diff --git a/bin/unit_tests/assets/textformat/french.utf8.lf.bom.txt b/bin/unit_tests/assets/textformat/french.utf8.lf.bom.txt new file mode 100644 index 000000000..fe75f78a2 --- /dev/null +++ b/bin/unit_tests/assets/textformat/french.utf8.lf.bom.txt @@ -0,0 +1,66 @@ +En 1815, M. Charles-François-Bienvenu Myriel était évêque de Digne. +C'était un vieillard d'environ soixante-quinze ans; il occupait le siège +de Digne depuis 1806. + +Quoique ce détail ne touche en aucune manière au fond même de ce que +nous avons à raconter, il n'est peut-être pas inutile, ne fût-ce que +pour être exact en tout, d'indiquer ici les bruits et les propos qui +avaient couru sur son compte au moment où il était arrivé dans le +diocèse. Vrai ou faux, ce qu'on dit des hommes tient souvent autant de +place dans leur vie et surtout dans leur destinée que ce qu'ils font. M. +Myriel était fils d'un conseiller au parlement d'Aix; noblesse de robe. +On contait de lui que son père, le réservant pour hériter de sa charge, +l'avait marié de fort bonne heure, à dix-huit ou vingt ans, suivant un +usage assez répandu dans les familles parlementaires. Charles Myriel, +nonobstant ce mariage, avait, disait-on, beaucoup fait parler de lui. Il +était bien fait de sa personne, quoique d'assez petite taille, élégant, +gracieux, spirituel; toute la première partie de sa vie avait été donnée +au monde et aux galanteries. La révolution survint, les événements se +précipitèrent, les familles parlementaires décimées, chassées, traquées, +se dispersèrent. M. Charles Myriel, dès les premiers jours de la +révolution, émigra en Italie. Sa femme y mourut d'une maladie de +poitrine dont elle était atteinte depuis longtemps. Ils n'avaient point +d'enfants. Que se passa-t-il ensuite dans la destinée de M. Myriel? +L'écroulement de l'ancienne société française, la chute de sa propre +famille, les tragiques spectacles de 93, plus effrayants encore +peut-être pour les émigrés qui les voyaient de loin avec le +grossissement de l'épouvante, firent-ils germer en lui des idées de +renoncement et de solitude? Fut-il, au milieu d'une de ces distractions +et de ces affections qui occupaient sa vie, subitement atteint d'un de +ces coups mystérieux et terribles qui viennent quelquefois renverser, en +le frappant au coeur, l'homme que les catastrophes publiques +n'ébranleraient pas en le frappant dans son existence et dans sa +fortune? Nul n'aurait pu le dire; tout ce qu'on savait, c'est que, +lorsqu'il revint d'Italie, il était prêtre. + +En 1804, M. Myriel était curé de Brignolles. Il était déjà vieux, et +vivait dans une retraite profonde. + +Vers l'époque du couronnement, une petite affaire de sa cure, on ne sait +plus trop quoi, l'amena à Paris. Entre autres personnes puissantes, il +alla solliciter pour ses paroissiens M. le cardinal Fesch. Un jour que +l'empereur était venu faire visite à son oncle, le digne curé, qui +attendait dans l'antichambre, se trouva sur le passage de sa majesté. +Napoléon, se voyant regardé avec une certaine curiosité par ce +vieillard, se retourna, et dit brusquement: + +--Quel est ce bonhomme qui me regarde? + +--Sire, dit M. Myriel, vous regardez un bonhomme, et moi je regarde un +grand homme. Chacun de nous peut profiter. + +L'empereur, le soir même, demanda au cardinal le nom de ce curé, et +quelque temps après M. Myriel fut tout surpris d'apprendre qu'il était +nommé évêque de Digne. + +Qu'y avait-il de vrai, du reste, dans les récits qu'on faisait sur la +première partie de la vie de M. Myriel? Personne ne le savait. Peu de +familles avaient connu la famille Myriel avant la révolution. + +M. Myriel devait subir le sort de tout nouveau venu dans une petite +ville où il y a beaucoup de bouches qui parlent et fort peu de têtes qui +pensent. Il devait le subir, quoiqu'il fût évêque et parce qu'il était +évêque. Mais, après tout, les propos auxquels on mêlait son nom +n'étaient peut-être que des propos; du bruit, des mots, des paroles; +moins que des paroles, des _palabres_, comme dit l'énergique langue du +midi. diff --git a/bin/unit_tests/assets/textformat/french.utf8.lf.nobom.txt b/bin/unit_tests/assets/textformat/french.utf8.lf.nobom.txt new file mode 100644 index 000000000..e142b06be --- /dev/null +++ b/bin/unit_tests/assets/textformat/french.utf8.lf.nobom.txt @@ -0,0 +1,66 @@ +En 1815, M. Charles-François-Bienvenu Myriel était évêque de Digne. +C'était un vieillard d'environ soixante-quinze ans; il occupait le siège +de Digne depuis 1806. + +Quoique ce détail ne touche en aucune manière au fond même de ce que +nous avons à raconter, il n'est peut-être pas inutile, ne fût-ce que +pour être exact en tout, d'indiquer ici les bruits et les propos qui +avaient couru sur son compte au moment où il était arrivé dans le +diocèse. Vrai ou faux, ce qu'on dit des hommes tient souvent autant de +place dans leur vie et surtout dans leur destinée que ce qu'ils font. M. +Myriel était fils d'un conseiller au parlement d'Aix; noblesse de robe. +On contait de lui que son père, le réservant pour hériter de sa charge, +l'avait marié de fort bonne heure, à dix-huit ou vingt ans, suivant un +usage assez répandu dans les familles parlementaires. Charles Myriel, +nonobstant ce mariage, avait, disait-on, beaucoup fait parler de lui. Il +était bien fait de sa personne, quoique d'assez petite taille, élégant, +gracieux, spirituel; toute la première partie de sa vie avait été donnée +au monde et aux galanteries. La révolution survint, les événements se +précipitèrent, les familles parlementaires décimées, chassées, traquées, +se dispersèrent. M. Charles Myriel, dès les premiers jours de la +révolution, émigra en Italie. Sa femme y mourut d'une maladie de +poitrine dont elle était atteinte depuis longtemps. Ils n'avaient point +d'enfants. Que se passa-t-il ensuite dans la destinée de M. Myriel? +L'écroulement de l'ancienne société française, la chute de sa propre +famille, les tragiques spectacles de 93, plus effrayants encore +peut-être pour les émigrés qui les voyaient de loin avec le +grossissement de l'épouvante, firent-ils germer en lui des idées de +renoncement et de solitude? Fut-il, au milieu d'une de ces distractions +et de ces affections qui occupaient sa vie, subitement atteint d'un de +ces coups mystérieux et terribles qui viennent quelquefois renverser, en +le frappant au coeur, l'homme que les catastrophes publiques +n'ébranleraient pas en le frappant dans son existence et dans sa +fortune? Nul n'aurait pu le dire; tout ce qu'on savait, c'est que, +lorsqu'il revint d'Italie, il était prêtre. + +En 1804, M. Myriel était curé de Brignolles. Il était déjà vieux, et +vivait dans une retraite profonde. + +Vers l'époque du couronnement, une petite affaire de sa cure, on ne sait +plus trop quoi, l'amena à Paris. Entre autres personnes puissantes, il +alla solliciter pour ses paroissiens M. le cardinal Fesch. Un jour que +l'empereur était venu faire visite à son oncle, le digne curé, qui +attendait dans l'antichambre, se trouva sur le passage de sa majesté. +Napoléon, se voyant regardé avec une certaine curiosité par ce +vieillard, se retourna, et dit brusquement: + +--Quel est ce bonhomme qui me regarde? + +--Sire, dit M. Myriel, vous regardez un bonhomme, et moi je regarde un +grand homme. Chacun de nous peut profiter. + +L'empereur, le soir même, demanda au cardinal le nom de ce curé, et +quelque temps après M. Myriel fut tout surpris d'apprendre qu'il était +nommé évêque de Digne. + +Qu'y avait-il de vrai, du reste, dans les récits qu'on faisait sur la +première partie de la vie de M. Myriel? Personne ne le savait. Peu de +familles avaient connu la famille Myriel avant la révolution. + +M. Myriel devait subir le sort de tout nouveau venu dans une petite +ville où il y a beaucoup de bouches qui parlent et fort peu de têtes qui +pensent. Il devait le subir, quoiqu'il fût évêque et parce qu'il était +évêque. Mais, après tout, les propos auxquels on mêlait son nom +n'étaient peut-être que des propos; du bruit, des mots, des paroles; +moins que des paroles, des _palabres_, comme dit l'énergique langue du +midi. diff --git a/bin/unit_tests/assets/textformat/french.win1252.crlf.nobom.txt b/bin/unit_tests/assets/textformat/french.win1252.crlf.nobom.txt new file mode 100644 index 000000000..0d77667f9 --- /dev/null +++ b/bin/unit_tests/assets/textformat/french.win1252.crlf.nobom.txt @@ -0,0 +1,66 @@ +En 1815, M. Charles-François-Bienvenu Myriel était évêque de Digne. +C'était un vieillard d'environ soixante-quinze ans; il occupait le siège +de Digne depuis 1806. + +Quoique ce détail ne touche en aucune manière au fond même de ce que +nous avons à raconter, il n'est peut-être pas inutile, ne fût-ce que +pour être exact en tout, d'indiquer ici les bruits et les propos qui +avaient couru sur son compte au moment où il était arrivé dans le +diocèse. Vrai ou faux, ce qu'on dit des hommes tient souvent autant de +place dans leur vie et surtout dans leur destinée que ce qu'ils font. M. +Myriel était fils d'un conseiller au parlement d'Aix; noblesse de robe. +On contait de lui que son père, le réservant pour hériter de sa charge, +l'avait marié de fort bonne heure, à dix-huit ou vingt ans, suivant un +usage assez répandu dans les familles parlementaires. Charles Myriel, +nonobstant ce mariage, avait, disait-on, beaucoup fait parler de lui. Il +était bien fait de sa personne, quoique d'assez petite taille, élégant, +gracieux, spirituel; toute la première partie de sa vie avait été donnée +au monde et aux galanteries. La révolution survint, les événements se +précipitèrent, les familles parlementaires décimées, chassées, traquées, +se dispersèrent. M. Charles Myriel, dès les premiers jours de la +révolution, émigra en Italie. Sa femme y mourut d'une maladie de +poitrine dont elle était atteinte depuis longtemps. Ils n'avaient point +d'enfants. Que se passa-t-il ensuite dans la destinée de M. Myriel? +L'écroulement de l'ancienne société française, la chute de sa propre +famille, les tragiques spectacles de 93, plus effrayants encore +peut-être pour les émigrés qui les voyaient de loin avec le +grossissement de l'épouvante, firent-ils germer en lui des idées de +renoncement et de solitude? Fut-il, au milieu d'une de ces distractions +et de ces affections qui occupaient sa vie, subitement atteint d'un de +ces coups mystérieux et terribles qui viennent quelquefois renverser, en +le frappant au coeur, l'homme que les catastrophes publiques +n'ébranleraient pas en le frappant dans son existence et dans sa +fortune? Nul n'aurait pu le dire; tout ce qu'on savait, c'est que, +lorsqu'il revint d'Italie, il était prêtre. + +En 1804, M. Myriel était curé de Brignolles. Il était déjà vieux, et +vivait dans une retraite profonde. + +Vers l'époque du couronnement, une petite affaire de sa cure, on ne sait +plus trop quoi, l'amena à Paris. Entre autres personnes puissantes, il +alla solliciter pour ses paroissiens M. le cardinal Fesch. Un jour que +l'empereur était venu faire visite à son oncle, le digne curé, qui +attendait dans l'antichambre, se trouva sur le passage de sa majesté. +Napoléon, se voyant regardé avec une certaine curiosité par ce +vieillard, se retourna, et dit brusquement: + +--Quel est ce bonhomme qui me regarde? + +--Sire, dit M. Myriel, vous regardez un bonhomme, et moi je regarde un +grand homme. Chacun de nous peut profiter. + +L'empereur, le soir même, demanda au cardinal le nom de ce curé, et +quelque temps après M. Myriel fut tout surpris d'apprendre qu'il était +nommé évêque de Digne. + +Qu'y avait-il de vrai, du reste, dans les récits qu'on faisait sur la +première partie de la vie de M. Myriel? Personne ne le savait. Peu de +familles avaient connu la famille Myriel avant la révolution. + +M. Myriel devait subir le sort de tout nouveau venu dans une petite +ville où il y a beaucoup de bouches qui parlent et fort peu de têtes qui +pensent. Il devait le subir, quoiqu'il fût évêque et parce qu'il était +évêque. Mais, après tout, les propos auxquels on mêlait son nom +n'étaient peut-être que des propos; du bruit, des mots, des paroles; +moins que des paroles, des _palabres_, comme dit l'énergique langue du +midi. diff --git a/bin/unit_tests/assets/textformat/french.win1252.lf.nobom.txt b/bin/unit_tests/assets/textformat/french.win1252.lf.nobom.txt new file mode 100644 index 000000000..2923d3797 --- /dev/null +++ b/bin/unit_tests/assets/textformat/french.win1252.lf.nobom.txt @@ -0,0 +1,66 @@ +En 1815, M. Charles-François-Bienvenu Myriel était évêque de Digne. +C'était un vieillard d'environ soixante-quinze ans; il occupait le siège +de Digne depuis 1806. + +Quoique ce détail ne touche en aucune manière au fond même de ce que +nous avons à raconter, il n'est peut-être pas inutile, ne fût-ce que +pour être exact en tout, d'indiquer ici les bruits et les propos qui +avaient couru sur son compte au moment où il était arrivé dans le +diocèse. Vrai ou faux, ce qu'on dit des hommes tient souvent autant de +place dans leur vie et surtout dans leur destinée que ce qu'ils font. M. +Myriel était fils d'un conseiller au parlement d'Aix; noblesse de robe. +On contait de lui que son père, le réservant pour hériter de sa charge, +l'avait marié de fort bonne heure, à dix-huit ou vingt ans, suivant un +usage assez répandu dans les familles parlementaires. Charles Myriel, +nonobstant ce mariage, avait, disait-on, beaucoup fait parler de lui. Il +était bien fait de sa personne, quoique d'assez petite taille, élégant, +gracieux, spirituel; toute la première partie de sa vie avait été donnée +au monde et aux galanteries. La révolution survint, les événements se +précipitèrent, les familles parlementaires décimées, chassées, traquées, +se dispersèrent. M. Charles Myriel, dès les premiers jours de la +révolution, émigra en Italie. Sa femme y mourut d'une maladie de +poitrine dont elle était atteinte depuis longtemps. Ils n'avaient point +d'enfants. Que se passa-t-il ensuite dans la destinée de M. Myriel? +L'écroulement de l'ancienne société française, la chute de sa propre +famille, les tragiques spectacles de 93, plus effrayants encore +peut-être pour les émigrés qui les voyaient de loin avec le +grossissement de l'épouvante, firent-ils germer en lui des idées de +renoncement et de solitude? Fut-il, au milieu d'une de ces distractions +et de ces affections qui occupaient sa vie, subitement atteint d'un de +ces coups mystérieux et terribles qui viennent quelquefois renverser, en +le frappant au coeur, l'homme que les catastrophes publiques +n'ébranleraient pas en le frappant dans son existence et dans sa +fortune? Nul n'aurait pu le dire; tout ce qu'on savait, c'est que, +lorsqu'il revint d'Italie, il était prêtre. + +En 1804, M. Myriel était curé de Brignolles. Il était déjà vieux, et +vivait dans une retraite profonde. + +Vers l'époque du couronnement, une petite affaire de sa cure, on ne sait +plus trop quoi, l'amena à Paris. Entre autres personnes puissantes, il +alla solliciter pour ses paroissiens M. le cardinal Fesch. Un jour que +l'empereur était venu faire visite à son oncle, le digne curé, qui +attendait dans l'antichambre, se trouva sur le passage de sa majesté. +Napoléon, se voyant regardé avec une certaine curiosité par ce +vieillard, se retourna, et dit brusquement: + +--Quel est ce bonhomme qui me regarde? + +--Sire, dit M. Myriel, vous regardez un bonhomme, et moi je regarde un +grand homme. Chacun de nous peut profiter. + +L'empereur, le soir même, demanda au cardinal le nom de ce curé, et +quelque temps après M. Myriel fut tout surpris d'apprendre qu'il était +nommé évêque de Digne. + +Qu'y avait-il de vrai, du reste, dans les récits qu'on faisait sur la +première partie de la vie de M. Myriel? Personne ne le savait. Peu de +familles avaient connu la famille Myriel avant la révolution. + +M. Myriel devait subir le sort de tout nouveau venu dans une petite +ville où il y a beaucoup de bouches qui parlent et fort peu de têtes qui +pensent. Il devait le subir, quoiqu'il fût évêque et parce qu'il était +évêque. Mais, après tout, les propos auxquels on mêlait son nom +n'étaient peut-être que des propos; du bruit, des mots, des paroles; +moins que des paroles, des _palabres_, comme dit l'énergique langue du +midi. diff --git a/bin/unit_tests/assets/textformat/japanese.shiftjis.crlf.nobom.txt b/bin/unit_tests/assets/textformat/japanese.shiftjis.crlf.nobom.txt new file mode 100644 index 000000000..a5ab83237 --- /dev/null +++ b/bin/unit_tests/assets/textformat/japanese.shiftjis.crlf.nobom.txt @@ -0,0 +1,48 @@ +�@Œá”y‚킪‚͂¢‚͔L‚ł ‚é�B–¼‘O‚͂܂¾–³‚¢�B + +�@‚ǂ±‚Ő¶‚ꂽ‚©‚Ƃñ‚ƌ©“–‚¯‚ñ‚Ƃ¤‚ª‚‚©‚ʁB‰½‚łà”–ˆÂ¢‚¶‚߂¶‚߂µ‚½�Š‚Ńjƒƒ�[ƒjƒƒ�[‹ƒ‚¢‚Ă¢‚½ +Ž–‚¾‚¯‚͋L‰¯‚µ‚Ă¢‚é�BŒá”y‚͂±‚±‚Ŏn‚߂ĐlŠԂƂ¢‚¤‚à‚̂ðŒ©‚½�B‚µ‚©‚à‚ ‚Ƃŕ·‚­‚Ƃ»‚ê‚͏‘�¶‚Ƃ¢ +‚¤�lŠԒ†‚ňê”Ôàֈ«‚ǂ¤‚ ‚­‚Ȏ푰‚ł ‚Á‚½‚»‚¤‚¾�B‚±‚̏‘�¶‚Ƃ¢‚¤‚͎̂ž�X‰ä�X‚ð•߂‚©‚܂¦‚ĎςɂÄ +�H‚¤‚Ƃ¢‚¤˜b‚ł ‚é�B‚µ‚©‚µ‚»‚̓–Žž‚͉½‚Ƃ¢‚¤�l‚à‚Ȃ©‚Á‚½‚©‚ç•ʒi‹°‚µ‚¢‚ƂàŽv‚í‚Ȃ©‚Á‚½�B‚½‚¾”Þ +‚̏¶‚Ă̂Ђç‚ɍڂ¹‚ç‚ê‚ăX�[‚Ǝ�‚¿�グ‚ç‚ꂽŽž‰½‚¾‚©ƒtƒ�ƒtƒ�‚µ‚½Š´‚¶‚ª‚ ‚Á‚½‚΂©‚è‚ł ‚é�B�¶‚Ì +�ã‚ŏ­‚µ—Ž‚¿‚‚¢‚ď‘�¶‚̊ç‚ðŒ©‚½‚̂ª‚¢‚í‚ä‚é�lŠԂƂ¢‚¤‚à‚̂̌©Žn‚݂͂¶‚߂ł ‚낤�B‚±‚̎ž–­‚Ȃà +‚̂¾‚Ǝv‚Á‚½Š´‚¶‚ª�¡‚łàŽc‚Á‚Ă¢‚é�B‘æˆê–тð‚à‚Á‚đ•�ü‚³‚ê‚ׂ«‚͂¸‚̊炪‚‚é‚‚邵‚Ă܂邪òŠÊ +‚₩‚񂾁B‚»‚̌ゲ”L‚ɂà‚¾‚¢‚Ԉ§‚ ‚Á‚½‚ª‚±‚ñ‚ȕЗւ©‚½‚í‚ɂ͈ê“x‚à�o‰ï‚ł­‚킵‚½Ž–‚ª‚Ȃ¢�B‚̂Ý +‚Ȃ炸Šç‚̐^’†‚ª‚ ‚܂è‚ɓˋN‚µ‚Ă¢‚é�B‚»‚¤‚µ‚Ă»‚̌Š‚̒†‚©‚玞�X‚Ղ¤‚Ղ¤‚ƉŒ‚¯‚ނè‚𐁂­�B‚ǂ¤ +‚àˆô‚ނ¹‚ۂ­‚ĎÀ‚Ɏã‚Á‚½�B‚±‚ꂪ�lŠԂ̈ù‚މŒ‘�‚½‚΂±‚Ƃ¢‚¤‚à‚̂ł ‚鎖‚͂悤‚₭‚±‚̍ ’m‚Á‚½�B + +�@‚±‚̏‘�¶‚̏¶‚̗ ‚¤‚¿‚łµ‚΂炭‚͂悢�SŽ�‚ɍ¿‚Á‚è‚Á‚½‚ª�A‚µ‚΂炭‚·‚é‚Ɣñ�í‚ȑ¬—͂ʼn^“]‚µŽn +‚߂½�B�‘�¶‚ª“®‚­‚̂©Ž©•ª‚¾‚¯‚ª“®‚­‚̂©•ª‚ç‚Ȃ¢‚ª–³ˆÂނâ‚݂ɊႪ‰ô‚é�B‹¹‚ªˆ«‚­‚Ȃé�B“ž’ê‚Ƃ¤‚Ä +‚¢�•‚©‚ç‚Ȃ¢‚Ǝv‚Á‚Ă¢‚é‚ƁA‚ǂ³‚è‚Ɖ¹‚ª‚µ‚ĊႩ‚ç‰΂ª�o‚½�B‚»‚ê‚܂ł͋L‰¯‚µ‚Ă¢‚邪‚ ‚Ƃ͉½‚Ì +Ž–‚â‚炢‚­‚ç�l‚¦�o‚»‚¤‚Ƃµ‚Ăà•ª‚ç‚Ȃ¢�B + +�@‚ӂƋC‚ª•t‚¢‚Č©‚é‚Ə‘�¶‚͂¢‚Ȃ¢�B‚½‚­‚³‚񂨂Á‚½ŒZ’킪ˆê•D‚҂«‚àŒ©‚¦‚ʁBŠ̐S‚©‚񂶂ñ‚̕ê�e‚³ +‚¦Žp‚ð‰B‚µ‚õ‚܂Á‚½�B‚»‚̏㍡‚¢‚܂܂ł̏Š‚Ƃ͈á‚Á‚˳ˆÂނâ‚݂ɖ¾‚邢�BŠá‚𖾂¢‚Ă¢‚ç‚ê‚ʂ­‚ç +‚¢‚¾�B‚͂Ăȉ½‚łà—eŽq‚悤‚·‚ª‚¨‚©‚µ‚¢‚ƁA‚̂»‚̂»”‡‚͂¢�o‚µ‚Č©‚é‚Ɣñ�í‚ɒɂ¢�BŒá”y‚͘m‚í‚ç‚Ì +�ォ‚ç‹}‚ɍùŒ´‚̒†‚֊ü‚Ăç‚ꂽ‚̂ł ‚é�B + +�@‚悤‚₭‚̎v‚¢‚ōùŒ´‚𔇂¢�o‚·‚ƌü‚¤‚ɑ傫‚Ȓr‚ª‚ ‚é�BŒá”y‚͒r‚̑O‚ɍ¿‚Á‚Ăǂ¤‚µ‚½‚ç‚悩‚낤 +‚ƍl‚¦‚Č©‚½�B•ʂɂ±‚ê‚Ƃ¢‚¤•ª•ʂӂñ‚ׂ‚à�o‚Ȃ¢�B‚µ‚΂炭‚µ‚ċƒ‚¢‚½‚珑�¶‚ª‚܂½Œ}‚ɗˆ‚Ă­‚ê‚é +‚©‚ƍl‚¦•t‚¢‚½�Bƒjƒƒ�[�Aƒjƒƒ�[‚ƎŽ‚݂ɂâ‚Á‚Č©‚½‚ª’N‚à—ˆ‚Ȃ¢�B‚»‚̂¤‚¿’r‚̏ã‚ð‚³‚炳‚ç‚ƕ—‚ª“n +‚Á‚ēú‚ª•é‚ꂩ‚©‚é�B• ‚ª”ñ�í‚Ɍ¸‚Á‚ėˆ‚½�B‹ƒ‚«‚½‚­‚Ăà�º‚ª�o‚Ȃ¢�BŽd•û‚ª‚Ȃ¢�A‰½‚łà‚悢‚©‚ç�H +•¨‚­‚¢‚à‚̂̂ ‚鏊‚܂ł ‚邱‚¤‚ƌˆ�S‚ð‚µ‚Ă»‚ë‚肻‚ë‚肃r‚ð�¶‚Ђ¾‚è‚ɉô‚èŽn‚߂½�B‚ǂ¤‚à”ñ�í‚É +‹ꂵ‚¢�B‚»‚±‚ð‰䖝‚µ‚˳—�‚â‚è‚ɔ‡‚͂Á‚čs‚­‚Ƃ悤‚₭‚̎–‚ʼn½‚ƂȂ­�lŠԏL‚¢�Š‚֏o‚½�B‚±‚±‚֔‡ +“ü‚͂¢‚Á‚½‚ç�A‚ǂ¤‚ɂ©‚Ȃé‚Ǝv‚Á‚Ē|Š_‚̕ö‚­‚¸‚ꂽŒŠ‚©‚ç�A‚Ƃ ‚é“@“à‚ɂà‚®‚荞‚񂾁B‰�‚͕sŽv‹c +‚Ȃà‚̂ŁA‚à‚µ‚±‚̒|Š_‚ª”j‚ê‚Ă¢‚Ȃ©‚Á‚½‚Ȃç�AŒá”y‚͂‚¢‚ɘH–T‚ë‚ڂ¤‚ɉ쎀‚ª‚µ‚µ‚½‚©‚à’m‚ê‚ñ‚Ì +‚ł ‚é�BˆêŽ÷‚̈ü‚Ƃ͂悭‰]‚¢‚Á‚½‚à‚̂¾�B‚±‚̊_�ª‚̌Š‚͍¡“ú‚±‚ñ‚ɂ¿‚ɎŠ‚é‚܂Ōá”y‚ª—׉ƂƂȂè‚Ì +ŽO–тð–K–₷‚鎞‚̒ʘH‚ɂȂÁ‚Ă¢‚é�B‚³‚ē@‚₵‚«‚ւ͔E‚эž‚񂾂à‚̂̂±‚ꂩ‚ç�æ‚ǂ¤‚µ‚đP‚¢‚¢‚© +•ª‚ç‚Ȃ¢�B‚»‚̂¤‚¿‚Ɉ­‚Ȃé�A• ‚͌¸‚é�AЦ‚³‚͊¦‚µ�A‰J‚ª�~‚Á‚ėˆ‚é‚Ƃ¢‚¤Žn––‚łà‚¤ˆꍏ‚̗P—\‚ä +‚¤‚悪�o—ˆ‚Ȃ­‚ȂÁ‚½�BŽd•û‚ª‚Ȃ¢‚©‚ç‚Ƃɂ©‚­–¾‚邭‚Ēg‚©‚»‚¤‚ȕû‚֕û‚ւƂ ‚邢‚čs‚­�B�¡‚©‚ç�l +‚¦‚é‚Ƃ»‚̎ž‚͂·‚łɉƂ̓à‚ɔ‡“ü‚Á‚è‚Á‚½‚̂¾�B‚±‚±‚Ōá”y‚͔ނ©‚̏‘�¶ˆȊO‚̐lŠԂð�Ăь©‚é‚ׂ« +‹@‰ï‚ɑ˜‹ö‚»‚¤‚®‚¤‚µ‚½‚̂ł ‚é�B‘æˆê‚Ɉ§‚Á‚½‚̂ª‚¨‚³‚ñ‚ł ‚é�B‚±‚ê‚͑O‚̏‘�¶‚æ‚èˆê‘w—�–\‚ȕû‚Å +Œá”y‚ðŒ©‚é‚â”ۂ₢‚«‚Ȃèèò‹؂­‚т·‚¶‚ð‚‚©‚ñ‚ŕ\‚֝e‚ق¤‚è�o‚µ‚½�B‚¢‚₱‚ê‚͑ʖڂ¾‚Ǝv‚Á‚½‚©‚ç +Šá‚ð‚˂ԂÁ‚ĉ^‚ð“V‚ɔC‚¹‚Ă¢‚½�B‚µ‚©‚µ‚Ђà‚¶‚¢‚̂Ɗ¦‚¢‚̂ɂ͂ǂ¤‚µ‚Ăà‰䖝‚ª�o—ˆ‚ñ�BŒá”y‚͍ĂÑ +‚¨‚³‚ñ‚̌„‚·‚«‚ðŒ©‚đ䏊‚֔‡‚͂¢�゠‚ª‚Á‚½�B‚·‚é‚ƊԂà‚Ȃ­‚܂½“Š‚°�o‚³‚ꂽ�BŒá”y‚͓Š‚°�o‚³‚ê‚Ä +‚͔‡‚¢�ã‚è�A”‡‚¢�ã‚Á‚Ă͓Š‚°�o‚³‚ê�A‰½‚łà“¯‚¶Ž–‚ðŽlŒܕՌJ‚è•Ԃµ‚½‚̂ð‹L‰¯‚µ‚Ă¢‚é�B‚»‚̎ž‚ɂ¨ +‚³‚ñ‚Ɖ]‚¤Ž҂͂‚­‚­‚¢‚â‚ɂȂÁ‚½�B‚±‚̊Ԃ¨‚³‚ñ‚̎O”n‚³‚ñ‚܂ð˜÷‚ʂ·‚ñ‚ł±‚̕ԕñ‚ð‚µ‚Ăâ‚Á‚Ă© +‚ç�A‚â‚Á‚Ƌ¹‚Ìá|‚‚©‚¦‚ª‰º‚肽�BŒá”y‚ª�Ōã‚ɂ‚܂ݏo‚³‚ê‚悤‚Ƃµ‚½‚Ƃ«‚ɁA‚±‚̉Ƃ¤‚¿‚̎å�l‚ª‘› +�X‚µ‚¢‰½‚¾‚Ƃ¢‚¢‚Ȃª‚ç�o‚ėˆ‚½�B‰º�—‚͌á”y‚ð‚Ԃ牺‚°‚Ďå�l‚̕û‚֌ü‚¯‚ñ‚̏h‚â‚ǂȂµ‚̏¬”L‚ª‚¢ +‚­‚ç�o‚µ‚Ăà�o‚µ‚ĂàŒä‘䏊‚¨‚¾‚¢‚ǂ±‚ë‚֏゠‚ª‚Á‚ėˆ‚č¢‚è‚܂·‚Ƃ¢‚¤�BŽå�l‚͕@‚̉º‚̍•‚¢–тð”Q +‚Ђ˂è‚Ȃª‚çŒá”y‚̊ç‚ð‚µ‚΂炭’­‚Ȃª‚߂è‚Á‚½‚ª�A‚₪‚Ă»‚ñ‚Ȃç“à‚֒u‚¢‚Ăâ‚ê‚Ƃ¢‚Á‚½‚܂܉œ‚Ö +”‡“ü‚͂¢‚Á‚õ‚܂Á‚½�BŽå�l‚͂ ‚܂èŒû‚𕷂©‚ʐl‚ƌ©‚¦‚½�B‰º�—‚͌û�ɂ­‚₵‚»‚¤‚Ɍá”y‚ð‘䏊‚֝e‚Ù +‚¤‚è�o‚µ‚½�B‚©‚­‚µ‚Čá”y‚͂‚¢‚ɂ±‚̉Ƃ¤‚¿‚ðŽ©•ª‚̏Z‰Ƃ·‚݂©‚Ƌɂ«‚߂鎖‚ɂµ‚½‚̂ł ‚é�B diff --git a/bin/unit_tests/assets/textformat/japanese.shiftjis.lf.nobom.txt b/bin/unit_tests/assets/textformat/japanese.shiftjis.lf.nobom.txt new file mode 100644 index 000000000..acff03e7c --- /dev/null +++ b/bin/unit_tests/assets/textformat/japanese.shiftjis.lf.nobom.txt @@ -0,0 +1,48 @@ +�@Œá”y‚킪‚͂¢‚͔L‚ł ‚é�B–¼‘O‚͂܂¾–³‚¢�B + +�@‚ǂ±‚Ő¶‚ꂽ‚©‚Ƃñ‚ƌ©“–‚¯‚ñ‚Ƃ¤‚ª‚‚©‚ʁB‰½‚łà”–ˆÂ¢‚¶‚߂¶‚߂µ‚½�Š‚Ńjƒƒ�[ƒjƒƒ�[‹ƒ‚¢‚Ă¢‚½ +Ž–‚¾‚¯‚͋L‰¯‚µ‚Ă¢‚é�BŒá”y‚͂±‚±‚Ŏn‚߂ĐlŠԂƂ¢‚¤‚à‚̂ðŒ©‚½�B‚µ‚©‚à‚ ‚Ƃŕ·‚­‚Ƃ»‚ê‚͏‘�¶‚Ƃ¢ +‚¤�lŠԒ†‚ňê”Ôàֈ«‚ǂ¤‚ ‚­‚Ȏ푰‚ł ‚Á‚½‚»‚¤‚¾�B‚±‚̏‘�¶‚Ƃ¢‚¤‚͎̂ž�X‰ä�X‚ð•߂‚©‚܂¦‚ĎςɂÄ +�H‚¤‚Ƃ¢‚¤˜b‚ł ‚é�B‚µ‚©‚µ‚»‚̓–Žž‚͉½‚Ƃ¢‚¤�l‚à‚Ȃ©‚Á‚½‚©‚ç•ʒi‹°‚µ‚¢‚ƂàŽv‚í‚Ȃ©‚Á‚½�B‚½‚¾”Þ +‚̏¶‚Ă̂Ђç‚ɍڂ¹‚ç‚ê‚ăX�[‚Ǝ�‚¿�グ‚ç‚ꂽŽž‰½‚¾‚©ƒtƒ�ƒtƒ�‚µ‚½Š´‚¶‚ª‚ ‚Á‚½‚΂©‚è‚ł ‚é�B�¶‚Ì +�ã‚ŏ­‚µ—Ž‚¿‚‚¢‚ď‘�¶‚̊ç‚ðŒ©‚½‚̂ª‚¢‚í‚ä‚é�lŠԂƂ¢‚¤‚à‚̂̌©Žn‚݂͂¶‚߂ł ‚낤�B‚±‚̎ž–­‚Ȃà +‚̂¾‚Ǝv‚Á‚½Š´‚¶‚ª�¡‚łàŽc‚Á‚Ă¢‚é�B‘æˆê–тð‚à‚Á‚đ•�ü‚³‚ê‚ׂ«‚͂¸‚̊炪‚‚é‚‚邵‚Ă܂邪òŠÊ +‚₩‚񂾁B‚»‚̌ゲ”L‚ɂà‚¾‚¢‚Ԉ§‚ ‚Á‚½‚ª‚±‚ñ‚ȕЗւ©‚½‚í‚ɂ͈ê“x‚à�o‰ï‚ł­‚킵‚½Ž–‚ª‚Ȃ¢�B‚̂Ý +‚Ȃ炸Šç‚̐^’†‚ª‚ ‚܂è‚ɓˋN‚µ‚Ă¢‚é�B‚»‚¤‚µ‚Ă»‚̌Š‚̒†‚©‚玞�X‚Ղ¤‚Ղ¤‚ƉŒ‚¯‚ނè‚𐁂­�B‚ǂ¤ +‚àˆô‚ނ¹‚ۂ­‚ĎÀ‚Ɏã‚Á‚½�B‚±‚ꂪ�lŠԂ̈ù‚މŒ‘�‚½‚΂±‚Ƃ¢‚¤‚à‚̂ł ‚鎖‚͂悤‚₭‚±‚̍ ’m‚Á‚½�B + +�@‚±‚̏‘�¶‚̏¶‚̗ ‚¤‚¿‚łµ‚΂炭‚͂悢�SŽ�‚ɍ¿‚Á‚è‚Á‚½‚ª�A‚µ‚΂炭‚·‚é‚Ɣñ�í‚ȑ¬—͂ʼn^“]‚µŽn +‚߂½�B�‘�¶‚ª“®‚­‚̂©Ž©•ª‚¾‚¯‚ª“®‚­‚̂©•ª‚ç‚Ȃ¢‚ª–³ˆÂނâ‚݂ɊႪ‰ô‚é�B‹¹‚ªˆ«‚­‚Ȃé�B“ž’ê‚Ƃ¤‚Ä +‚¢�•‚©‚ç‚Ȃ¢‚Ǝv‚Á‚Ă¢‚é‚ƁA‚ǂ³‚è‚Ɖ¹‚ª‚µ‚ĊႩ‚ç‰΂ª�o‚½�B‚»‚ê‚܂ł͋L‰¯‚µ‚Ă¢‚邪‚ ‚Ƃ͉½‚Ì +Ž–‚â‚炢‚­‚ç�l‚¦�o‚»‚¤‚Ƃµ‚Ăà•ª‚ç‚Ȃ¢�B + +�@‚ӂƋC‚ª•t‚¢‚Č©‚é‚Ə‘�¶‚͂¢‚Ȃ¢�B‚½‚­‚³‚񂨂Á‚½ŒZ’킪ˆê•D‚҂«‚àŒ©‚¦‚ʁBŠ̐S‚©‚񂶂ñ‚̕ê�e‚³ +‚¦Žp‚ð‰B‚µ‚õ‚܂Á‚½�B‚»‚̏㍡‚¢‚܂܂ł̏Š‚Ƃ͈á‚Á‚˳ˆÂނâ‚݂ɖ¾‚邢�BŠá‚𖾂¢‚Ă¢‚ç‚ê‚ʂ­‚ç +‚¢‚¾�B‚͂Ăȉ½‚łà—eŽq‚悤‚·‚ª‚¨‚©‚µ‚¢‚ƁA‚̂»‚̂»”‡‚͂¢�o‚µ‚Č©‚é‚Ɣñ�í‚ɒɂ¢�BŒá”y‚͘m‚í‚ç‚Ì +�ォ‚ç‹}‚ɍùŒ´‚̒†‚֊ü‚Ăç‚ꂽ‚̂ł ‚é�B + +�@‚悤‚₭‚̎v‚¢‚ōùŒ´‚𔇂¢�o‚·‚ƌü‚¤‚ɑ傫‚Ȓr‚ª‚ ‚é�BŒá”y‚͒r‚̑O‚ɍ¿‚Á‚Ăǂ¤‚µ‚½‚ç‚悩‚낤 +‚ƍl‚¦‚Č©‚½�B•ʂɂ±‚ê‚Ƃ¢‚¤•ª•ʂӂñ‚ׂ‚à�o‚Ȃ¢�B‚µ‚΂炭‚µ‚ċƒ‚¢‚½‚珑�¶‚ª‚܂½Œ}‚ɗˆ‚Ă­‚ê‚é +‚©‚ƍl‚¦•t‚¢‚½�Bƒjƒƒ�[�Aƒjƒƒ�[‚ƎŽ‚݂ɂâ‚Á‚Č©‚½‚ª’N‚à—ˆ‚Ȃ¢�B‚»‚̂¤‚¿’r‚̏ã‚ð‚³‚炳‚ç‚ƕ—‚ª“n +‚Á‚ēú‚ª•é‚ꂩ‚©‚é�B• ‚ª”ñ�í‚Ɍ¸‚Á‚ėˆ‚½�B‹ƒ‚«‚½‚­‚Ăà�º‚ª�o‚Ȃ¢�BŽd•û‚ª‚Ȃ¢�A‰½‚łà‚悢‚©‚ç�H +•¨‚­‚¢‚à‚̂̂ ‚鏊‚܂ł ‚邱‚¤‚ƌˆ�S‚ð‚µ‚Ă»‚ë‚肻‚ë‚肃r‚ð�¶‚Ђ¾‚è‚ɉô‚èŽn‚߂½�B‚ǂ¤‚à”ñ�í‚É +‹ꂵ‚¢�B‚»‚±‚ð‰䖝‚µ‚˳—�‚â‚è‚ɔ‡‚͂Á‚čs‚­‚Ƃ悤‚₭‚̎–‚ʼn½‚ƂȂ­�lŠԏL‚¢�Š‚֏o‚½�B‚±‚±‚֔‡ +“ü‚͂¢‚Á‚½‚ç�A‚ǂ¤‚ɂ©‚Ȃé‚Ǝv‚Á‚Ē|Š_‚̕ö‚­‚¸‚ꂽŒŠ‚©‚ç�A‚Ƃ ‚é“@“à‚ɂà‚®‚荞‚񂾁B‰�‚͕sŽv‹c +‚Ȃà‚̂ŁA‚à‚µ‚±‚̒|Š_‚ª”j‚ê‚Ă¢‚Ȃ©‚Á‚½‚Ȃç�AŒá”y‚͂‚¢‚ɘH–T‚ë‚ڂ¤‚ɉ쎀‚ª‚µ‚µ‚½‚©‚à’m‚ê‚ñ‚Ì +‚ł ‚é�BˆêŽ÷‚̈ü‚Ƃ͂悭‰]‚¢‚Á‚½‚à‚̂¾�B‚±‚̊_�ª‚̌Š‚͍¡“ú‚±‚ñ‚ɂ¿‚ɎŠ‚é‚܂Ōá”y‚ª—׉ƂƂȂè‚Ì +ŽO–тð–K–₷‚鎞‚̒ʘH‚ɂȂÁ‚Ă¢‚é�B‚³‚ē@‚₵‚«‚ւ͔E‚эž‚񂾂à‚̂̂±‚ꂩ‚ç�æ‚ǂ¤‚µ‚đP‚¢‚¢‚© +•ª‚ç‚Ȃ¢�B‚»‚̂¤‚¿‚Ɉ­‚Ȃé�A• ‚͌¸‚é�AЦ‚³‚͊¦‚µ�A‰J‚ª�~‚Á‚ėˆ‚é‚Ƃ¢‚¤Žn––‚łà‚¤ˆꍏ‚̗P—\‚ä +‚¤‚悪�o—ˆ‚Ȃ­‚ȂÁ‚½�BŽd•û‚ª‚Ȃ¢‚©‚ç‚Ƃɂ©‚­–¾‚邭‚Ēg‚©‚»‚¤‚ȕû‚֕û‚ւƂ ‚邢‚čs‚­�B�¡‚©‚ç�l +‚¦‚é‚Ƃ»‚̎ž‚͂·‚łɉƂ̓à‚ɔ‡“ü‚Á‚è‚Á‚½‚̂¾�B‚±‚±‚Ōá”y‚͔ނ©‚̏‘�¶ˆȊO‚̐lŠԂð�Ăь©‚é‚ׂ« +‹@‰ï‚ɑ˜‹ö‚»‚¤‚®‚¤‚µ‚½‚̂ł ‚é�B‘æˆê‚Ɉ§‚Á‚½‚̂ª‚¨‚³‚ñ‚ł ‚é�B‚±‚ê‚͑O‚̏‘�¶‚æ‚èˆê‘w—�–\‚ȕû‚Å +Œá”y‚ðŒ©‚é‚â”ۂ₢‚«‚Ȃèèò‹؂­‚т·‚¶‚ð‚‚©‚ñ‚ŕ\‚֝e‚ق¤‚è�o‚µ‚½�B‚¢‚₱‚ê‚͑ʖڂ¾‚Ǝv‚Á‚½‚©‚ç +Šá‚ð‚˂ԂÁ‚ĉ^‚ð“V‚ɔC‚¹‚Ă¢‚½�B‚µ‚©‚µ‚Ђà‚¶‚¢‚̂Ɗ¦‚¢‚̂ɂ͂ǂ¤‚µ‚Ăà‰䖝‚ª�o—ˆ‚ñ�BŒá”y‚͍ĂÑ +‚¨‚³‚ñ‚̌„‚·‚«‚ðŒ©‚đ䏊‚֔‡‚͂¢�゠‚ª‚Á‚½�B‚·‚é‚ƊԂà‚Ȃ­‚܂½“Š‚°�o‚³‚ꂽ�BŒá”y‚͓Š‚°�o‚³‚ê‚Ä +‚͔‡‚¢�ã‚è�A”‡‚¢�ã‚Á‚Ă͓Š‚°�o‚³‚ê�A‰½‚łà“¯‚¶Ž–‚ðŽlŒܕՌJ‚è•Ԃµ‚½‚̂ð‹L‰¯‚µ‚Ă¢‚é�B‚»‚̎ž‚ɂ¨ +‚³‚ñ‚Ɖ]‚¤Ž҂͂‚­‚­‚¢‚â‚ɂȂÁ‚½�B‚±‚̊Ԃ¨‚³‚ñ‚̎O”n‚³‚ñ‚܂ð˜÷‚ʂ·‚ñ‚ł±‚̕ԕñ‚ð‚µ‚Ăâ‚Á‚Ă© +‚ç�A‚â‚Á‚Ƌ¹‚Ìá|‚‚©‚¦‚ª‰º‚肽�BŒá”y‚ª�Ōã‚ɂ‚܂ݏo‚³‚ê‚悤‚Ƃµ‚½‚Ƃ«‚ɁA‚±‚̉Ƃ¤‚¿‚̎å�l‚ª‘› +�X‚µ‚¢‰½‚¾‚Ƃ¢‚¢‚Ȃª‚ç�o‚ėˆ‚½�B‰º�—‚͌á”y‚ð‚Ԃ牺‚°‚Ďå�l‚̕û‚֌ü‚¯‚ñ‚̏h‚â‚ǂȂµ‚̏¬”L‚ª‚¢ +‚­‚ç�o‚µ‚Ăà�o‚µ‚ĂàŒä‘䏊‚¨‚¾‚¢‚ǂ±‚ë‚֏゠‚ª‚Á‚ėˆ‚č¢‚è‚܂·‚Ƃ¢‚¤�BŽå�l‚͕@‚̉º‚̍•‚¢–тð”Q +‚Ђ˂è‚Ȃª‚çŒá”y‚̊ç‚ð‚µ‚΂炭’­‚Ȃª‚߂è‚Á‚½‚ª�A‚₪‚Ă»‚ñ‚Ȃç“à‚֒u‚¢‚Ăâ‚ê‚Ƃ¢‚Á‚½‚܂܉œ‚Ö +”‡“ü‚͂¢‚Á‚õ‚܂Á‚½�BŽå�l‚͂ ‚܂èŒû‚𕷂©‚ʐl‚ƌ©‚¦‚½�B‰º�—‚͌û�ɂ­‚₵‚»‚¤‚Ɍá”y‚ð‘䏊‚֝e‚Ù +‚¤‚è�o‚µ‚½�B‚©‚­‚µ‚Čá”y‚͂‚¢‚ɂ±‚̉Ƃ¤‚¿‚ðŽ©•ª‚̏Z‰Ƃ·‚݂©‚Ƌɂ«‚߂鎖‚ɂµ‚½‚̂ł ‚é�B diff --git a/bin/unit_tests/assets/textformat/japanese.utf16be.crlf.bom.txt b/bin/unit_tests/assets/textformat/japanese.utf16be.crlf.bom.txt new file mode 100644 index 000000000..eb2412f06 Binary files /dev/null and b/bin/unit_tests/assets/textformat/japanese.utf16be.crlf.bom.txt differ diff --git a/bin/unit_tests/assets/textformat/japanese.utf16be.crlf.nobom.txt b/bin/unit_tests/assets/textformat/japanese.utf16be.crlf.nobom.txt new file mode 100644 index 000000000..516c21116 Binary files /dev/null and b/bin/unit_tests/assets/textformat/japanese.utf16be.crlf.nobom.txt differ diff --git a/bin/unit_tests/assets/textformat/japanese.utf16be.lf.bom.txt b/bin/unit_tests/assets/textformat/japanese.utf16be.lf.bom.txt new file mode 100644 index 000000000..25f30ed86 Binary files /dev/null and b/bin/unit_tests/assets/textformat/japanese.utf16be.lf.bom.txt differ diff --git a/bin/unit_tests/assets/textformat/japanese.utf16be.lf.nobom.txt b/bin/unit_tests/assets/textformat/japanese.utf16be.lf.nobom.txt new file mode 100644 index 000000000..1fc4606f6 Binary files /dev/null and b/bin/unit_tests/assets/textformat/japanese.utf16be.lf.nobom.txt differ diff --git a/bin/unit_tests/assets/textformat/japanese.utf16le.crlf.bom.txt b/bin/unit_tests/assets/textformat/japanese.utf16le.crlf.bom.txt new file mode 100644 index 000000000..279659b73 Binary files /dev/null and b/bin/unit_tests/assets/textformat/japanese.utf16le.crlf.bom.txt differ diff --git a/bin/unit_tests/assets/textformat/japanese.utf16le.crlf.nobom.txt b/bin/unit_tests/assets/textformat/japanese.utf16le.crlf.nobom.txt new file mode 100644 index 000000000..6dabfd126 Binary files /dev/null and b/bin/unit_tests/assets/textformat/japanese.utf16le.crlf.nobom.txt differ diff --git a/bin/unit_tests/assets/textformat/japanese.utf16le.lf.bom.txt b/bin/unit_tests/assets/textformat/japanese.utf16le.lf.bom.txt new file mode 100644 index 000000000..4781331e8 Binary files /dev/null and b/bin/unit_tests/assets/textformat/japanese.utf16le.lf.bom.txt differ diff --git a/bin/unit_tests/assets/textformat/japanese.utf16le.lf.nobom.txt b/bin/unit_tests/assets/textformat/japanese.utf16le.lf.nobom.txt new file mode 100644 index 000000000..625901306 Binary files /dev/null and b/bin/unit_tests/assets/textformat/japanese.utf16le.lf.nobom.txt differ diff --git a/bin/unit_tests/assets/textformat/japanese.utf8.crlf.bom.txt b/bin/unit_tests/assets/textformat/japanese.utf8.crlf.bom.txt new file mode 100644 index 000000000..e1582a34a --- /dev/null +++ b/bin/unit_tests/assets/textformat/japanese.utf8.crlf.bom.txt @@ -0,0 +1,48 @@ + 吾輩わがはいは猫である。名前はまだ無い。 + + どこで生れたかとんと見当けんとうがつかぬ。何でも薄暗いじめじめした所でニャーニャー泣いていた +事だけは記憶している。吾輩はここで始めて人間というものを見た。しかもあとで聞くとそれは書生とい +う人間中で一番獰悪どうあくな種族であったそうだ。この書生というのは時々我々を捕つかまえて煮にて +食うという話である。しかしその当時は何という考もなかったから別段恐しいとも思わなかった。ただ彼 +の掌てのひらに載せられてスーと持ち上げられた時何だかフワフワした感じがあったばかりである。掌の +上で少し落ちついて書生の顔を見たのがいわゆる人間というものの見始みはじめであろう。この時妙なも +のだと思った感じが今でも残っている。第一毛をもって装飾されべきはずの顔がつるつるしてまるで薬缶 +やかんだ。その後ご猫にもだいぶ逢あったがこんな片輪かたわには一度も出会でくわした事がない。のみ +ならず顔の真中があまりに突起している。そうしてその穴の中から時々ぷうぷうと煙けむりを吹く。どう +も咽むせぽくて実に弱った。これが人間の飲む煙草たばこというものである事はようやくこの頃知った。 + + この書生の掌の裏うちでしばらくはよい心持に坐っておったが、しばらくすると非常な速力で運転し始 +めた。書生が動くのか自分だけが動くのか分らないが無暗むやみに眼が廻る。胸が悪くなる。到底とうて +い助からないと思っていると、どさりと音がして眼から火が出た。それまでは記憶しているがあとは何の +事やらいくら考え出そうとしても分らない。 + + ふと気が付いて見ると書生はいない。たくさんおった兄弟が一疋ぴきも見えぬ。肝心かんじんの母親さ +え姿を隠してしまった。その上今いままでの所とは違って無暗むやみに明るい。眼を明いていられぬくら +いだ。はてな何でも容子ようすがおかしいと、のそのそ這はい出して見ると非常に痛い。吾輩は藁わらの +上から急に笹原の中へ棄てられたのである。 + + ようやくの思いで笹原を這い出すと向うに大きな池がある。吾輩は池の前に坐ってどうしたらよかろう +と考えて見た。別にこれという分別ふんべつも出ない。しばらくして泣いたら書生がまた迎に来てくれる +かと考え付いた。ニャー、ニャーと試みにやって見たが誰も来ない。そのうち池の上をさらさらと風が渡 +って日が暮れかかる。腹が非常に減って来た。泣きたくても声が出ない。仕方がない、何でもよいから食 +物くいもののある所まであるこうと決心をしてそろりそろりと池を左ひだりに廻り始めた。どうも非常に +苦しい。そこを我慢して無理やりに這はって行くとようやくの事で何となく人間臭い所へ出た。ここへ這 +入はいったら、どうにかなると思って竹垣の崩くずれた穴から、とある邸内にもぐり込んだ。縁は不思議 +なもので、もしこの竹垣が破れていなかったなら、吾輩はついに路傍ろぼうに餓死がししたかも知れんの +である。一樹の蔭とはよく云いったものだ。この垣根の穴は今日こんにちに至るまで吾輩が隣家となりの +三毛を訪問する時の通路になっている。さて邸やしきへは忍び込んだもののこれから先どうして善いいか +分らない。そのうちに暗くなる、腹は減る、寒さは寒し、雨が降って来るという始末でもう一刻の猶予ゆ +うよが出来なくなった。仕方がないからとにかく明るくて暖かそうな方へ方へとあるいて行く。今から考 +えるとその時はすでに家の内に這入っておったのだ。ここで吾輩は彼かの書生以外の人間を再び見るべき +機会に遭遇そうぐうしたのである。第一に逢ったのがおさんである。これは前の書生より一層乱暴な方で +吾輩を見るや否やいきなり頸筋くびすじをつかんで表へ抛ほうり出した。いやこれは駄目だと思ったから +眼をねぶって運を天に任せていた。しかしひもじいのと寒いのにはどうしても我慢が出来ん。吾輩は再び +おさんの隙すきを見て台所へ這はい上あがった。すると間もなくまた投げ出された。吾輩は投げ出されて +は這い上り、這い上っては投げ出され、何でも同じ事を四五遍繰り返したのを記憶している。その時にお +さんと云う者はつくづくいやになった。この間おさんの三馬さんまを偸ぬすんでこの返報をしてやってか +ら、やっと胸の痞つかえが下りた。吾輩が最後につまみ出されようとしたときに、この家うちの主人が騒 +々しい何だといいながら出て来た。下女は吾輩をぶら下げて主人の方へ向けてこの宿やどなしの小猫がい +くら出しても出しても御台所おだいどころへ上あがって来て困りますという。主人は鼻の下の黒い毛を撚 +ひねりながら吾輩の顔をしばらく眺ながめておったが、やがてそんなら内へ置いてやれといったまま奥へ +這入はいってしまった。主人はあまり口を聞かぬ人と見えた。下女は口惜くやしそうに吾輩を台所へ抛ほ +うり出した。かくして吾輩はついにこの家うちを自分の住家すみかと極きめる事にしたのである。 diff --git a/bin/unit_tests/assets/textformat/japanese.utf8.crlf.nobom.txt b/bin/unit_tests/assets/textformat/japanese.utf8.crlf.nobom.txt new file mode 100644 index 000000000..686953022 --- /dev/null +++ b/bin/unit_tests/assets/textformat/japanese.utf8.crlf.nobom.txt @@ -0,0 +1,48 @@ + 吾輩わがはいは猫である。名前はまだ無い。 + + どこで生れたかとんと見当けんとうがつかぬ。何でも薄暗いじめじめした所でニャーニャー泣いていた +事だけは記憶している。吾輩はここで始めて人間というものを見た。しかもあとで聞くとそれは書生とい +う人間中で一番獰悪どうあくな種族であったそうだ。この書生というのは時々我々を捕つかまえて煮にて +食うという話である。しかしその当時は何という考もなかったから別段恐しいとも思わなかった。ただ彼 +の掌てのひらに載せられてスーと持ち上げられた時何だかフワフワした感じがあったばかりである。掌の +上で少し落ちついて書生の顔を見たのがいわゆる人間というものの見始みはじめであろう。この時妙なも +のだと思った感じが今でも残っている。第一毛をもって装飾されべきはずの顔がつるつるしてまるで薬缶 +やかんだ。その後ご猫にもだいぶ逢あったがこんな片輪かたわには一度も出会でくわした事がない。のみ +ならず顔の真中があまりに突起している。そうしてその穴の中から時々ぷうぷうと煙けむりを吹く。どう +も咽むせぽくて実に弱った。これが人間の飲む煙草たばこというものである事はようやくこの頃知った。 + + この書生の掌の裏うちでしばらくはよい心持に坐っておったが、しばらくすると非常な速力で運転し始 +めた。書生が動くのか自分だけが動くのか分らないが無暗むやみに眼が廻る。胸が悪くなる。到底とうて +い助からないと思っていると、どさりと音がして眼から火が出た。それまでは記憶しているがあとは何の +事やらいくら考え出そうとしても分らない。 + + ふと気が付いて見ると書生はいない。たくさんおった兄弟が一疋ぴきも見えぬ。肝心かんじんの母親さ +え姿を隠してしまった。その上今いままでの所とは違って無暗むやみに明るい。眼を明いていられぬくら +いだ。はてな何でも容子ようすがおかしいと、のそのそ這はい出して見ると非常に痛い。吾輩は藁わらの +上から急に笹原の中へ棄てられたのである。 + + ようやくの思いで笹原を這い出すと向うに大きな池がある。吾輩は池の前に坐ってどうしたらよかろう +と考えて見た。別にこれという分別ふんべつも出ない。しばらくして泣いたら書生がまた迎に来てくれる +かと考え付いた。ニャー、ニャーと試みにやって見たが誰も来ない。そのうち池の上をさらさらと風が渡 +って日が暮れかかる。腹が非常に減って来た。泣きたくても声が出ない。仕方がない、何でもよいから食 +物くいもののある所まであるこうと決心をしてそろりそろりと池を左ひだりに廻り始めた。どうも非常に +苦しい。そこを我慢して無理やりに這はって行くとようやくの事で何となく人間臭い所へ出た。ここへ這 +入はいったら、どうにかなると思って竹垣の崩くずれた穴から、とある邸内にもぐり込んだ。縁は不思議 +なもので、もしこの竹垣が破れていなかったなら、吾輩はついに路傍ろぼうに餓死がししたかも知れんの +である。一樹の蔭とはよく云いったものだ。この垣根の穴は今日こんにちに至るまで吾輩が隣家となりの +三毛を訪問する時の通路になっている。さて邸やしきへは忍び込んだもののこれから先どうして善いいか +分らない。そのうちに暗くなる、腹は減る、寒さは寒し、雨が降って来るという始末でもう一刻の猶予ゆ +うよが出来なくなった。仕方がないからとにかく明るくて暖かそうな方へ方へとあるいて行く。今から考 +えるとその時はすでに家の内に這入っておったのだ。ここで吾輩は彼かの書生以外の人間を再び見るべき +機会に遭遇そうぐうしたのである。第一に逢ったのがおさんである。これは前の書生より一層乱暴な方で +吾輩を見るや否やいきなり頸筋くびすじをつかんで表へ抛ほうり出した。いやこれは駄目だと思ったから +眼をねぶって運を天に任せていた。しかしひもじいのと寒いのにはどうしても我慢が出来ん。吾輩は再び +おさんの隙すきを見て台所へ這はい上あがった。すると間もなくまた投げ出された。吾輩は投げ出されて +は這い上り、這い上っては投げ出され、何でも同じ事を四五遍繰り返したのを記憶している。その時にお +さんと云う者はつくづくいやになった。この間おさんの三馬さんまを偸ぬすんでこの返報をしてやってか +ら、やっと胸の痞つかえが下りた。吾輩が最後につまみ出されようとしたときに、この家うちの主人が騒 +々しい何だといいながら出て来た。下女は吾輩をぶら下げて主人の方へ向けてこの宿やどなしの小猫がい +くら出しても出しても御台所おだいどころへ上あがって来て困りますという。主人は鼻の下の黒い毛を撚 +ひねりながら吾輩の顔をしばらく眺ながめておったが、やがてそんなら内へ置いてやれといったまま奥へ +這入はいってしまった。主人はあまり口を聞かぬ人と見えた。下女は口惜くやしそうに吾輩を台所へ抛ほ +うり出した。かくして吾輩はついにこの家うちを自分の住家すみかと極きめる事にしたのである。 diff --git a/bin/unit_tests/assets/textformat/japanese.utf8.lf.bom.txt b/bin/unit_tests/assets/textformat/japanese.utf8.lf.bom.txt new file mode 100644 index 000000000..5cbd1e681 --- /dev/null +++ b/bin/unit_tests/assets/textformat/japanese.utf8.lf.bom.txt @@ -0,0 +1,48 @@ + 吾輩わがはいは猫である。名前はまだ無い。 + + どこで生れたかとんと見当けんとうがつかぬ。何でも薄暗いじめじめした所でニャーニャー泣いていた +事だけは記憶している。吾輩はここで始めて人間というものを見た。しかもあとで聞くとそれは書生とい +う人間中で一番獰悪どうあくな種族であったそうだ。この書生というのは時々我々を捕つかまえて煮にて +食うという話である。しかしその当時は何という考もなかったから別段恐しいとも思わなかった。ただ彼 +の掌てのひらに載せられてスーと持ち上げられた時何だかフワフワした感じがあったばかりである。掌の +上で少し落ちついて書生の顔を見たのがいわゆる人間というものの見始みはじめであろう。この時妙なも +のだと思った感じが今でも残っている。第一毛をもって装飾されべきはずの顔がつるつるしてまるで薬缶 +やかんだ。その後ご猫にもだいぶ逢あったがこんな片輪かたわには一度も出会でくわした事がない。のみ +ならず顔の真中があまりに突起している。そうしてその穴の中から時々ぷうぷうと煙けむりを吹く。どう +も咽むせぽくて実に弱った。これが人間の飲む煙草たばこというものである事はようやくこの頃知った。 + + この書生の掌の裏うちでしばらくはよい心持に坐っておったが、しばらくすると非常な速力で運転し始 +めた。書生が動くのか自分だけが動くのか分らないが無暗むやみに眼が廻る。胸が悪くなる。到底とうて +い助からないと思っていると、どさりと音がして眼から火が出た。それまでは記憶しているがあとは何の +事やらいくら考え出そうとしても分らない。 + + ふと気が付いて見ると書生はいない。たくさんおった兄弟が一疋ぴきも見えぬ。肝心かんじんの母親さ +え姿を隠してしまった。その上今いままでの所とは違って無暗むやみに明るい。眼を明いていられぬくら +いだ。はてな何でも容子ようすがおかしいと、のそのそ這はい出して見ると非常に痛い。吾輩は藁わらの +上から急に笹原の中へ棄てられたのである。 + + ようやくの思いで笹原を這い出すと向うに大きな池がある。吾輩は池の前に坐ってどうしたらよかろう +と考えて見た。別にこれという分別ふんべつも出ない。しばらくして泣いたら書生がまた迎に来てくれる +かと考え付いた。ニャー、ニャーと試みにやって見たが誰も来ない。そのうち池の上をさらさらと風が渡 +って日が暮れかかる。腹が非常に減って来た。泣きたくても声が出ない。仕方がない、何でもよいから食 +物くいもののある所まであるこうと決心をしてそろりそろりと池を左ひだりに廻り始めた。どうも非常に +苦しい。そこを我慢して無理やりに這はって行くとようやくの事で何となく人間臭い所へ出た。ここへ這 +入はいったら、どうにかなると思って竹垣の崩くずれた穴から、とある邸内にもぐり込んだ。縁は不思議 +なもので、もしこの竹垣が破れていなかったなら、吾輩はついに路傍ろぼうに餓死がししたかも知れんの +である。一樹の蔭とはよく云いったものだ。この垣根の穴は今日こんにちに至るまで吾輩が隣家となりの +三毛を訪問する時の通路になっている。さて邸やしきへは忍び込んだもののこれから先どうして善いいか +分らない。そのうちに暗くなる、腹は減る、寒さは寒し、雨が降って来るという始末でもう一刻の猶予ゆ +うよが出来なくなった。仕方がないからとにかく明るくて暖かそうな方へ方へとあるいて行く。今から考 +えるとその時はすでに家の内に這入っておったのだ。ここで吾輩は彼かの書生以外の人間を再び見るべき +機会に遭遇そうぐうしたのである。第一に逢ったのがおさんである。これは前の書生より一層乱暴な方で +吾輩を見るや否やいきなり頸筋くびすじをつかんで表へ抛ほうり出した。いやこれは駄目だと思ったから +眼をねぶって運を天に任せていた。しかしひもじいのと寒いのにはどうしても我慢が出来ん。吾輩は再び +おさんの隙すきを見て台所へ這はい上あがった。すると間もなくまた投げ出された。吾輩は投げ出されて +は這い上り、這い上っては投げ出され、何でも同じ事を四五遍繰り返したのを記憶している。その時にお +さんと云う者はつくづくいやになった。この間おさんの三馬さんまを偸ぬすんでこの返報をしてやってか +ら、やっと胸の痞つかえが下りた。吾輩が最後につまみ出されようとしたときに、この家うちの主人が騒 +々しい何だといいながら出て来た。下女は吾輩をぶら下げて主人の方へ向けてこの宿やどなしの小猫がい +くら出しても出しても御台所おだいどころへ上あがって来て困りますという。主人は鼻の下の黒い毛を撚 +ひねりながら吾輩の顔をしばらく眺ながめておったが、やがてそんなら内へ置いてやれといったまま奥へ +這入はいってしまった。主人はあまり口を聞かぬ人と見えた。下女は口惜くやしそうに吾輩を台所へ抛ほ +うり出した。かくして吾輩はついにこの家うちを自分の住家すみかと極きめる事にしたのである。 diff --git a/bin/unit_tests/assets/textformat/japanese.utf8.lf.nobom.txt b/bin/unit_tests/assets/textformat/japanese.utf8.lf.nobom.txt new file mode 100644 index 000000000..c06950d54 --- /dev/null +++ b/bin/unit_tests/assets/textformat/japanese.utf8.lf.nobom.txt @@ -0,0 +1,48 @@ + 吾輩わがはいは猫である。名前はまだ無い。 + + どこで生れたかとんと見当けんとうがつかぬ。何でも薄暗いじめじめした所でニャーニャー泣いていた +事だけは記憶している。吾輩はここで始めて人間というものを見た。しかもあとで聞くとそれは書生とい +う人間中で一番獰悪どうあくな種族であったそうだ。この書生というのは時々我々を捕つかまえて煮にて +食うという話である。しかしその当時は何という考もなかったから別段恐しいとも思わなかった。ただ彼 +の掌てのひらに載せられてスーと持ち上げられた時何だかフワフワした感じがあったばかりである。掌の +上で少し落ちついて書生の顔を見たのがいわゆる人間というものの見始みはじめであろう。この時妙なも +のだと思った感じが今でも残っている。第一毛をもって装飾されべきはずの顔がつるつるしてまるで薬缶 +やかんだ。その後ご猫にもだいぶ逢あったがこんな片輪かたわには一度も出会でくわした事がない。のみ +ならず顔の真中があまりに突起している。そうしてその穴の中から時々ぷうぷうと煙けむりを吹く。どう +も咽むせぽくて実に弱った。これが人間の飲む煙草たばこというものである事はようやくこの頃知った。 + + この書生の掌の裏うちでしばらくはよい心持に坐っておったが、しばらくすると非常な速力で運転し始 +めた。書生が動くのか自分だけが動くのか分らないが無暗むやみに眼が廻る。胸が悪くなる。到底とうて +い助からないと思っていると、どさりと音がして眼から火が出た。それまでは記憶しているがあとは何の +事やらいくら考え出そうとしても分らない。 + + ふと気が付いて見ると書生はいない。たくさんおった兄弟が一疋ぴきも見えぬ。肝心かんじんの母親さ +え姿を隠してしまった。その上今いままでの所とは違って無暗むやみに明るい。眼を明いていられぬくら +いだ。はてな何でも容子ようすがおかしいと、のそのそ這はい出して見ると非常に痛い。吾輩は藁わらの +上から急に笹原の中へ棄てられたのである。 + + ようやくの思いで笹原を這い出すと向うに大きな池がある。吾輩は池の前に坐ってどうしたらよかろう +と考えて見た。別にこれという分別ふんべつも出ない。しばらくして泣いたら書生がまた迎に来てくれる +かと考え付いた。ニャー、ニャーと試みにやって見たが誰も来ない。そのうち池の上をさらさらと風が渡 +って日が暮れかかる。腹が非常に減って来た。泣きたくても声が出ない。仕方がない、何でもよいから食 +物くいもののある所まであるこうと決心をしてそろりそろりと池を左ひだりに廻り始めた。どうも非常に +苦しい。そこを我慢して無理やりに這はって行くとようやくの事で何となく人間臭い所へ出た。ここへ這 +入はいったら、どうにかなると思って竹垣の崩くずれた穴から、とある邸内にもぐり込んだ。縁は不思議 +なもので、もしこの竹垣が破れていなかったなら、吾輩はついに路傍ろぼうに餓死がししたかも知れんの +である。一樹の蔭とはよく云いったものだ。この垣根の穴は今日こんにちに至るまで吾輩が隣家となりの +三毛を訪問する時の通路になっている。さて邸やしきへは忍び込んだもののこれから先どうして善いいか +分らない。そのうちに暗くなる、腹は減る、寒さは寒し、雨が降って来るという始末でもう一刻の猶予ゆ +うよが出来なくなった。仕方がないからとにかく明るくて暖かそうな方へ方へとあるいて行く。今から考 +えるとその時はすでに家の内に這入っておったのだ。ここで吾輩は彼かの書生以外の人間を再び見るべき +機会に遭遇そうぐうしたのである。第一に逢ったのがおさんである。これは前の書生より一層乱暴な方で +吾輩を見るや否やいきなり頸筋くびすじをつかんで表へ抛ほうり出した。いやこれは駄目だと思ったから +眼をねぶって運を天に任せていた。しかしひもじいのと寒いのにはどうしても我慢が出来ん。吾輩は再び +おさんの隙すきを見て台所へ這はい上あがった。すると間もなくまた投げ出された。吾輩は投げ出されて +は這い上り、這い上っては投げ出され、何でも同じ事を四五遍繰り返したのを記憶している。その時にお +さんと云う者はつくづくいやになった。この間おさんの三馬さんまを偸ぬすんでこの返報をしてやってか +ら、やっと胸の痞つかえが下りた。吾輩が最後につまみ出されようとしたときに、この家うちの主人が騒 +々しい何だといいながら出て来た。下女は吾輩をぶら下げて主人の方へ向けてこの宿やどなしの小猫がい +くら出しても出しても御台所おだいどころへ上あがって来て困りますという。主人は鼻の下の黒い毛を撚 +ひねりながら吾輩の顔をしばらく眺ながめておったが、やがてそんなら内へ置いてやれといったまま奥へ +這入はいってしまった。主人はあまり口を聞かぬ人と見えた。下女は口惜くやしそうに吾輩を台所へ抛ほ +うり出した。かくして吾輩はついにこの家うちを自分の住家すみかと極きめる事にしたのである。 diff --git a/premake4.lua b/premake4.lua index 7f43480ba..38e4e310c 100644 --- a/premake4.lua +++ b/premake4.lua @@ -1542,6 +1542,13 @@ solution "eepp" includedirs { "src/thirdparty" } build_link_configuration( "eepp-ui-perf-test", true ) + project "eepp-unit_tests" + set_kind() + targetdir("./bin/unit_tests") + language "C++" + files { "src/tests/unit_tests/*.cpp" } + build_link_configuration( "eepp-unit_tests", true ) + if os.isfile("external_projects.lua") then dofile("external_projects.lua") end diff --git a/premake5.lua b/premake5.lua index 3b72f5eca..917d71634 100644 --- a/premake5.lua +++ b/premake5.lua @@ -1302,6 +1302,13 @@ workspace "eepp" includedirs { "src/thirdparty" } build_link_configuration( "eepp-ui-perf-test", true ) + project "eepp-unit_tests" + set_kind() + targetdir("./bin/unit_tests") + language "C++" + files { "src/tests/unit_tests/*.cpp" } + build_link_configuration( "eepp-unit_tests", true ) + if os.isfile("external_projects.lua") then dofile("external_projects.lua") end diff --git a/projects/linux/ee.creator.user b/projects/linux/ee.creator.user index 867321776..5f7665549 100644 --- a/projects/linux/ee.creator.user +++ b/projects/linux/ee.creator.user @@ -1,6 +1,6 @@ - + EnvironmentId @@ -1390,6 +1390,28 @@ false %{buildDir}/../../bin + + true + 0 + true + true + + 2 + + false + -e cpu-cycles --call-graph dwarf,4096 -F 250 + %{buildDir}/../../bin/unit_tests/eepp-unit_tests-debug + eepp-unit_tests-debug + ProjectExplorer.CustomExecutableRunConfiguration + + true + 0 + false + 1 + false + false + %{buildDir}/../../bin + true 0 @@ -1539,7 +1561,7 @@ false %{buildDir}../../../bin/ - 28 + 29 diff --git a/projects/linux/ee.files b/projects/linux/ee.files index 91c9fc1af..78771cc75 100644 --- a/projects/linux/ee.files +++ b/projects/linux/ee.files @@ -1433,6 +1433,9 @@ ../../src/tests/test_everything/test.cpp ../../src/tests/test_everything/test.hpp ../../src/tests/ui_perf_test/ui_perf_test.cpp +../../src/tests/unit_tests/main.cpp +../../src/tests/unit_tests/textformat.cpp +../../src/tests/unit_tests/utest.h ../../src/thirdparty/SOIL2/src/SOIL2/etc1_utils.c ../../src/thirdparty/SOIL2/src/SOIL2/etc1_utils.h ../../src/thirdparty/SOIL2/src/SOIL2/image_DXT.c diff --git a/src/eepp/ui/doc/textformat.cpp b/src/eepp/ui/doc/textformat.cpp index f75be661a..b802150d5 100644 --- a/src/eepp/ui/doc/textformat.cpp +++ b/src/eepp/ui/doc/textformat.cpp @@ -309,14 +309,18 @@ struct TextFileStats { } void calcScore() { - if ( !score ) { - score = ( 2.5f * numWhitespace + numPlainAscii - 100.f * numInvalidPoints() - - 50.f * numControl + 5.f * numExtended + 2.5f * num16bytes ) * - ooNumPoints; - } + score = ( ( 2.5f * numWhitespace + numPlainAscii - 100.f * numInvalidPoints() - + 50.f * numControl + 5.f * numExtended + 2.5f * num16bytes ) * + ( count16b ? ( num16bytes > 0 ? 1 : 0 ) : 1 ) ) * + ooNumPoints; } - float getScore() const { return score; } + bool allValidPoints() const { return numPoints == numValidPoints; } + + float getScore() { + calcScore(); + return score; + } }; static Uint32 scanTextFile( TextFileStats& stats, IOStream& ins, const TextEncoding* encoding, @@ -435,7 +439,8 @@ TextFormat guessFileEncoding( IOStream& ins ) { scanTextFile( statsShiftJIS, ins, TextEncoding::get(), NumBytesForAutodetect ); ins.seek( 0 ); - if ( statsShiftJIS.getScore() > stats->getScore() ) { + if ( statsShiftJIS.allValidPoints() && statsShiftJIS.num16bytes && + statsShiftJIS.getScore() > stats->getScore() ) { stats = &statsShiftJIS; encoding = TextFormat::Encoding::Shift_JIS; } @@ -473,7 +478,7 @@ TextFormat TextFormat::autodetect( IOStream& ins ) { tff.encoding = TextFormat::Encoding::UTF16BE; tff.bom = true; } else if ( h[0] == 0xff && h[1] == 0xfe ) { - tff.encoding = TextFormat::Encoding::UTF16BE; + tff.encoding = TextFormat::Encoding::UTF16LE; tff.bom = true; } ins.seek( start ); diff --git a/src/tests/unit_tests/main.cpp b/src/tests/unit_tests/main.cpp new file mode 100644 index 000000000..30dad370e --- /dev/null +++ b/src/tests/unit_tests/main.cpp @@ -0,0 +1,3 @@ +#include "utest.h" + +UTEST_MAIN() diff --git a/src/tests/unit_tests/textformat.cpp b/src/tests/unit_tests/textformat.cpp new file mode 100644 index 000000000..f076ef2bc --- /dev/null +++ b/src/tests/unit_tests/textformat.cpp @@ -0,0 +1,104 @@ +#include "utest.h" +#include +#include +#include +#include +#include +#include + +using namespace EE::Graphics; +using namespace EE::System; +using namespace EE::UI::Doc; + +TextFormat::Encoding encodingFromString( const std::string_view& str ) { + if ( str == "utf16be" ) + return TextFormat::Encoding::UTF16BE; + if ( str == "utf16le" ) + return TextFormat::Encoding::UTF16LE; + if ( str == "win1252" ) + return TextFormat::Encoding::Latin1; + if ( str == "shiftjis" ) + return TextFormat::Encoding::Shift_JIS; + if ( str == "utf8" ) + return TextFormat::Encoding::UTF8; + return TextFormat::Encoding::UTF8; +} + +UTEST( TextFormat, autodetect ) { + FileSystem::changeWorkingDirectory( Sys::getProcessPath() ); + auto files = FileSystem::filesInfoGetInPath( std::string{ "assets/textformat" }, false, true ); + for ( const auto& file : files ) { + if ( file.isDirectory() ) + continue; + auto fnParts( String::split( file.getFileName(), '.' ) ); + ASSERT_EQ( fnParts.size(), 5UL ); + auto lang = fnParts[0]; + auto encoding = encodingFromString( fnParts[1] ); + auto newLine = TextFormat::stringToLineEnding( String::toUpper( fnParts[2] ) ); + auto bom = fnParts[3] == "bom"; + IOStreamFile stream( file.getFilepath() ); + auto textFormat = TextFormat::autodetect( stream ); + ASSERT_EQ_MSG( + textFormat.bom, bom, + String::format( "%s %d vs %d", file.getFileName(), textFormat.bom, bom ).c_str() ); + ASSERT_EQ_MSG( textFormat.encoding, encoding, + String::format( "%s %s vs %s", file.getFileName(), + TextFormat::encodingToString( textFormat.encoding ), + TextFormat::encodingToString( encoding ) ) + .c_str() ); + ASSERT_EQ_MSG( textFormat.newLine, newLine, + String::format( "%s %s vs %s", file.getFileName(), + TextFormat::lineEndingToString( textFormat.newLine ), + TextFormat::lineEndingToString( newLine ) ) + .c_str() ); + } +} + +UTEST( TextFormat, autodetectProject ) { + std::string projectRoot = Sys::getProcessPath(); + FileSystem::dirRemoveSlashAtEnd( projectRoot ); + projectRoot = FileSystem::fileRemoveFileName( projectRoot ); + FileSystem::dirRemoveSlashAtEnd( projectRoot ); + projectRoot = FileSystem::fileRemoveFileName( projectRoot ) + "src"; + std::function checkFolder; + auto getEncoding = []( const std::string& filename ) { + static std::unordered_map KNOWN_ENCS = { + { "SDL_sunaudio.c", TextFormat::Encoding::Latin1 }, + { "default_cursor.h", TextFormat::Encoding::Latin1 }, + { "InfoPlist.strings", TextFormat::Encoding::UTF16BE }, + { "version.rc", TextFormat::Encoding::Latin1 }, + { "SDL_RLEaccel.c", TextFormat::Encoding::Latin1 }, + { "func_common.hpp", TextFormat::Encoding::Latin1 }, + { "func_common.inl", TextFormat::Encoding::Latin1 }, + { "type_half.inl", TextFormat::Encoding::Latin1 }, + }; + auto found = KNOWN_ENCS.find( filename ); + if ( found != KNOWN_ENCS.end() ) + return found->second; + return TextFormat::Encoding::UTF8; + }; + checkFolder = [&]( const std::string& folder ) { + auto files = FileSystem::filesInfoGetInPath( folder, false, true, true, true ); + for ( const auto& file : files ) { + if ( file.isDirectory() ) { + checkFolder( file.getFilepath() ); + continue; + } + auto extension = file.getExtension(); + if ( "a" == extension || "zip" == extension || "dll" == extension || + "dat" == extension || "cur" == extension || "icns" == extension || + "wav" == extension || Image::isImageExtension( file.getFilepath() ) || + LuaPattern::matches( file.getFilepath(), "SDL2%-%d+%.%d+%.%d+" ) ) + continue; + IOStreamFile stream( file.getFilepath() ); + auto expectedEncoding = getEncoding( file.getFileName() ); + auto textFormat = TextFormat::autodetect( stream ); + EXPECT_EQ_MSG( textFormat.encoding, expectedEncoding, + String::format( "%s %s vs %s", file.getFilepath(), + TextFormat::encodingToString( textFormat.encoding ), + TextFormat::encodingToString( expectedEncoding ) ) + .c_str() ); + } + }; + checkFolder( projectRoot ); +} diff --git a/src/tests/unit_tests/utest.h b/src/tests/unit_tests/utest.h new file mode 100644 index 000000000..5dc25b14c --- /dev/null +++ b/src/tests/unit_tests/utest.h @@ -0,0 +1,1700 @@ +/* + The latest version of this library is available on GitHub; + https://github.com/sheredom/utest.h +*/ + +/* + This is free and unencumbered software released into the public domain. + + Anyone is free to copy, modify, publish, use, compile, sell, or + distribute this software, either in source code form or as a compiled + binary, for any purpose, commercial or non-commercial, and by any + means. + + In jurisdictions that recognize copyright laws, the author or authors + of this software dedicate any and all copyright interest in the + software to the public domain. We make this dedication for the benefit + of the public at large and to the detriment of our heirs and + successors. We intend this dedication to be an overt act of + relinquishment in perpetuity of all present and future rights to this + software under copyright law. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR + OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + OTHER DEALINGS IN THE SOFTWARE. + + For more information, please refer to +*/ + +#ifndef SHEREDOM_UTEST_H_INCLUDED +#define SHEREDOM_UTEST_H_INCLUDED + +#ifdef _MSC_VER +/* + Disable warning about not inlining 'inline' functions. +*/ +#pragma warning(disable : 4710) + +/* + Disable warning about inlining functions that are not marked 'inline'. +*/ +#pragma warning(disable : 4711) + +/* + Disable warning for alignment padding added +*/ +#pragma warning(disable : 4820) + +#if _MSC_VER > 1900 +/* + Disable warning about preprocessor macros not being defined in MSVC headers. +*/ +#pragma warning(disable : 4668) + +/* + Disable warning about no function prototype given in MSVC headers. +*/ +#pragma warning(disable : 4255) + +/* + Disable warning about pointer or reference to potentially throwing function. +*/ +#pragma warning(disable : 5039) + +/* + Disable warning about macro expansion producing 'defined' has undefined + behavior. +*/ +#pragma warning(disable : 5105) +#endif + +#if _MSC_VER > 1930 +/* + Disable warning about 'const' variable is not used. +*/ +#pragma warning(disable : 5264) +#endif + +#pragma warning(push, 1) +#endif + +#if defined(_MSC_VER) && (_MSC_VER < 1920) +typedef __int64 utest_int64_t; +typedef unsigned __int64 utest_uint64_t; +typedef unsigned __int32 utest_uint32_t; +#else +#include +typedef int64_t utest_int64_t; +typedef uint64_t utest_uint64_t; +typedef uint32_t utest_uint32_t; +#endif + +#include +#include +#include +#include +#include + +#if defined(__cplusplus) +#if defined(_MSC_VER) && !defined(_CPPUNWIND) +/* We're on MSVC and the compiler is compiling without exception support! */ +#elif !defined(_MSC_VER) && !defined(__EXCEPTIONS) +/* We're on a GCC/Clang compiler that doesn't have exception support! */ +#else +#define UTEST_HAS_EXCEPTIONS 1 +#endif +#endif + +#if defined(UTEST_HAS_EXCEPTIONS) +#include +#endif + +#if defined(_MSC_VER) +#pragma warning(pop) +#endif + +#if defined(__cplusplus) +#define UTEST_C_FUNC extern "C" +#else +#define UTEST_C_FUNC +#endif + +#define UTEST_TEST_PASSED (0) +#define UTEST_TEST_FAILURE (1) +#define UTEST_TEST_SKIPPED (2) + +#if defined(__TINYC__) +#define UTEST_ATTRIBUTE(a) __attribute((a)) +#else +#define UTEST_ATTRIBUTE(a) __attribute__((a)) +#endif + +#if defined(_MSC_VER) || defined(__MINGW64__) || defined(__MINGW32__) + +#if defined(__MINGW64__) || defined(__MINGW32__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wpragmas" +#pragma GCC diagnostic ignored "-Wunknown-pragmas" +#endif + +#if defined(_WINDOWS_) || defined(_WINDOWS_H) +typedef LARGE_INTEGER utest_large_integer; +#else +// use old QueryPerformanceCounter definitions (not sure is this needed in some +// edge cases or not) on Win7 with VS2015 these extern declaration cause "second +// C linkage of overloaded function not allowed" error +typedef union { + struct { + unsigned long LowPart; + long HighPart; + } DUMMYSTRUCTNAME; + struct { + unsigned long LowPart; + long HighPart; + } u; + utest_int64_t QuadPart; +} utest_large_integer; + +UTEST_C_FUNC __declspec(dllimport) int __stdcall QueryPerformanceCounter( + utest_large_integer *); +UTEST_C_FUNC __declspec(dllimport) int __stdcall QueryPerformanceFrequency( + utest_large_integer *); + +#if defined(__MINGW64__) || defined(__MINGW32__) +#pragma GCC diagnostic pop +#endif +#endif + +#elif defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__) || \ + defined(__NetBSD__) || defined(__DragonFly__) || defined(__sun__) || \ + defined(__HAIKU__) +/* + slightly obscure include here - we need to include glibc's features.h, but + we don't want to just include a header that might not be defined for other + c libraries like musl. Instead we include limits.h, which we know on all + glibc distributions includes features.h +*/ +#include + +#if defined(__GLIBC__) && defined(__GLIBC_MINOR__) +#include + +#if ((2 < __GLIBC__) || ((2 == __GLIBC__) && (17 <= __GLIBC_MINOR__))) +/* glibc is version 2.17 or above, so we can just use clock_gettime */ +#define UTEST_USE_CLOCKGETTIME +#else +#include +#include +#endif +#else // Other libc implementations +#include +#define UTEST_USE_CLOCKGETTIME +#endif + +#elif defined(__APPLE__) +#include +#endif + +#if defined(_MSC_VER) && (_MSC_VER < 1920) +#define UTEST_PRId64 "I64d" +#define UTEST_PRIu64 "I64u" +#else +#include + +#define UTEST_PRId64 PRId64 +#define UTEST_PRIu64 PRIu64 +#endif + +#if defined(__cplusplus) +#define UTEST_INLINE inline + +#if defined(__clang__) +#define UTEST_INITIALIZER_BEGIN_DISABLE_WARNINGS \ + _Pragma("clang diagnostic push") \ + _Pragma("clang diagnostic ignored \"-Wglobal-constructors\"") + +#define UTEST_INITIALIZER_END_DISABLE_WARNINGS _Pragma("clang diagnostic pop") +#else +#define UTEST_INITIALIZER_BEGIN_DISABLE_WARNINGS +#define UTEST_INITIALIZER_END_DISABLE_WARNINGS +#endif + +#define UTEST_INITIALIZER(f) \ + struct f##_cpp_struct { \ + f##_cpp_struct(); \ + }; \ + UTEST_INITIALIZER_BEGIN_DISABLE_WARNINGS static f##_cpp_struct \ + f##_cpp_global UTEST_INITIALIZER_END_DISABLE_WARNINGS; \ + f##_cpp_struct::f##_cpp_struct() +#elif defined(_MSC_VER) +#define UTEST_INLINE __forceinline + +#if defined(_WIN64) +#define UTEST_SYMBOL_PREFIX +#else +#define UTEST_SYMBOL_PREFIX "_" +#endif + +#if defined(__clang__) +#define UTEST_INITIALIZER_BEGIN_DISABLE_WARNINGS \ + _Pragma("clang diagnostic push") \ + _Pragma("clang diagnostic ignored \"-Wmissing-variable-declarations\"") + +#define UTEST_INITIALIZER_END_DISABLE_WARNINGS _Pragma("clang diagnostic pop") +#else +#define UTEST_INITIALIZER_BEGIN_DISABLE_WARNINGS +#define UTEST_INITIALIZER_END_DISABLE_WARNINGS +#endif + +#pragma section(".CRT$XCU", read) +#define UTEST_INITIALIZER(f) \ + static void __cdecl f(void); \ + UTEST_INITIALIZER_BEGIN_DISABLE_WARNINGS \ + __pragma(comment(linker, "/include:" UTEST_SYMBOL_PREFIX #f "_")) \ + UTEST_C_FUNC __declspec(allocate(".CRT$XCU")) void(__cdecl * \ + f##_)(void) = f; \ + UTEST_INITIALIZER_END_DISABLE_WARNINGS \ + static void __cdecl f(void) +#else +#if defined(__linux__) +#if defined(__clang__) +#if __has_warning("-Wreserved-id-macro") +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wreserved-id-macro" +#endif +#endif + +#define __STDC_FORMAT_MACROS 1 + +#if defined(__clang__) +#if __has_warning("-Wreserved-id-macro") +#pragma clang diagnostic pop +#endif +#endif +#endif + +#define UTEST_INLINE inline + +#define UTEST_INITIALIZER(f) \ + static void f(void) UTEST_ATTRIBUTE(constructor); \ + static void f(void) +#endif + +#if defined(__cplusplus) +#define UTEST_CAST(type, x) static_cast(x) +#define UTEST_PTR_CAST(type, x) reinterpret_cast(x) +#define UTEST_EXTERN extern "C" +#define UTEST_NULL NULL +#else +#define UTEST_CAST(type, x) ((type)(x)) +#define UTEST_PTR_CAST(type, x) ((type)(x)) +#define UTEST_EXTERN extern +#define UTEST_NULL 0 +#endif + +#ifdef _MSC_VER +/* + io.h contains definitions for some structures with natural padding. This is + uninteresting, but for some reason MSVC's behaviour is to warn about + including this system header. That *is* interesting +*/ +#pragma warning(disable : 4820) +#pragma warning(push, 1) +#include +#pragma warning(pop) +#define UTEST_COLOUR_OUTPUT() (_isatty(_fileno(stdout))) +#else +#if defined(__EMSCRIPTEN__) +#include +#define UTEST_COLOUR_OUTPUT() false +#else +#include +#define UTEST_COLOUR_OUTPUT() (isatty(STDOUT_FILENO)) +#endif +#endif + +static UTEST_INLINE void *utest_realloc(void *const pointer, size_t new_size) { + void *const new_pointer = realloc(pointer, new_size); + + if (UTEST_NULL == new_pointer) { + free(pointer); + } + + return new_pointer; +} + +static UTEST_INLINE utest_int64_t utest_ns(void) { +#if defined(_MSC_VER) || defined(__MINGW64__) || defined(__MINGW32__) + utest_large_integer counter; + utest_large_integer frequency; + QueryPerformanceCounter(&counter); + QueryPerformanceFrequency(&frequency); + return UTEST_CAST(utest_int64_t, + (counter.QuadPart * 1000000000) / frequency.QuadPart); +#elif defined(__linux__) && defined(__STRICT_ANSI__) + return UTEST_CAST(utest_int64_t, clock()) * 1000000000 / CLOCKS_PER_SEC; +#elif defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__) || \ + defined(__NetBSD__) || defined(__DragonFly__) || defined(__sun__) || \ + defined(__HAIKU__) + struct timespec ts; +#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L) && \ + !defined(__HAIKU__) + timespec_get(&ts, TIME_UTC); +#else + const clockid_t cid = CLOCK_REALTIME; +#if defined(UTEST_USE_CLOCKGETTIME) + clock_gettime(cid, &ts); +#else + syscall(SYS_clock_gettime, cid, &ts); +#endif +#endif + return UTEST_CAST(utest_int64_t, ts.tv_sec) * 1000 * 1000 * 1000 + ts.tv_nsec; +#elif __APPLE__ + return UTEST_CAST(utest_int64_t, clock_gettime_nsec_np(CLOCK_UPTIME_RAW)); +#elif __EMSCRIPTEN__ + return emscripten_performance_now() * 1000000.0; +#else +#error Unsupported platform! +#endif +} + +typedef void (*utest_testcase_t)(int *, size_t); + +struct utest_test_state_s { + utest_testcase_t func; + size_t index; + char *name; +}; + +struct utest_state_s { + struct utest_test_state_s *tests; + size_t tests_length; + FILE *output; +}; + +/* extern to the global state utest needs to execute */ +UTEST_EXTERN struct utest_state_s utest_state; + +#if defined(_MSC_VER) +#define UTEST_WEAK __forceinline +#elif defined(__MINGW32__) || defined(__MINGW64__) +#define UTEST_WEAK static UTEST_ATTRIBUTE(used) +#elif defined(__clang__) || defined(__GNUC__) || defined(__TINYC__) +#define UTEST_WEAK UTEST_ATTRIBUTE(weak) +#else +#error Non clang, non gcc, non MSVC, non tcc compiler found! +#endif + +#if defined(_MSC_VER) +#define UTEST_UNUSED +#else +#define UTEST_UNUSED UTEST_ATTRIBUTE(unused) +#endif + +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wvariadic-macros" +#pragma clang diagnostic ignored "-Wc++98-compat-pedantic" +#endif +#define UTEST_PRINTF(...) \ + if (utest_state.output) { \ + fprintf(utest_state.output, __VA_ARGS__); \ + } \ + printf(__VA_ARGS__) +#ifdef __clang__ +#pragma clang diagnostic pop +#endif + +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wvariadic-macros" +#pragma clang diagnostic ignored "-Wc++98-compat-pedantic" +#endif + +#ifdef _MSC_VER +#define UTEST_SNPRINTF(BUFFER, N, ...) _snprintf_s(BUFFER, N, N, __VA_ARGS__) +#else +#define UTEST_SNPRINTF(...) snprintf(__VA_ARGS__) +#endif + +#ifdef __clang__ +#pragma clang diagnostic pop +#endif + +#if defined(__cplusplus) +/* if we are using c++ we can use overloaded methods (its in the language) */ +#define UTEST_OVERLOADABLE +#elif defined(__clang__) +/* otherwise, if we are using clang with c - use the overloadable attribute */ +#define UTEST_OVERLOADABLE UTEST_ATTRIBUTE(overloadable) +#endif + +#if defined(__cplusplus) && (__cplusplus >= 201103L) + +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wc++98-compat-pedantic" +#endif + +#include + +template ::value> +struct utest_type_deducer final { + static void _(const T t); +}; + +template <> struct utest_type_deducer { + static void _(const signed char c) { + UTEST_PRINTF("%d", static_cast(c)); + } +}; + +template <> struct utest_type_deducer { + static void _(const unsigned char c) { + UTEST_PRINTF("%u", static_cast(c)); + } +}; + +template <> struct utest_type_deducer { + static void _(const short s) { UTEST_PRINTF("%d", static_cast(s)); } +}; + +template <> struct utest_type_deducer { + static void _(const unsigned short s) { + UTEST_PRINTF("%u", static_cast(s)); + } +}; + +template <> struct utest_type_deducer { + static void _(const float f) { UTEST_PRINTF("%f", static_cast(f)); } +}; + +template <> struct utest_type_deducer { + static void _(const double d) { UTEST_PRINTF("%f", d); } +}; + +template <> struct utest_type_deducer { + static void _(const long double d) { +#if defined(__MINGW32__) || defined(__MINGW64__) + /* MINGW is weird - doesn't like LF at all?! */ + UTEST_PRINTF("%f", (double)d); +#else + UTEST_PRINTF("%Lf", d); +#endif + } +}; + +template <> struct utest_type_deducer { + static void _(const int i) { UTEST_PRINTF("%d", i); } +}; + +template <> struct utest_type_deducer { + static void _(const unsigned int i) { UTEST_PRINTF("%u", i); } +}; + +template <> struct utest_type_deducer { + static void _(const long i) { UTEST_PRINTF("%ld", i); } +}; + +template <> struct utest_type_deducer { + static void _(const unsigned long i) { UTEST_PRINTF("%lu", i); } +}; + +template <> struct utest_type_deducer { + static void _(const long long i) { UTEST_PRINTF("%lld", i); } +}; + +template <> struct utest_type_deducer { + static void _(const unsigned long long i) { UTEST_PRINTF("%llu", i); } +}; + +template <> struct utest_type_deducer { + static void _(const bool i) { UTEST_PRINTF(i ? "true" : "false"); } +}; + +template struct utest_type_deducer { + static void _(const T *t) { + UTEST_PRINTF("%p", static_cast(const_cast(t))); + } +}; + +template struct utest_type_deducer { + static void _(T *t) { UTEST_PRINTF("%p", static_cast(t)); } +}; + +template struct utest_type_deducer { + static void _(const T t) { + UTEST_PRINTF("%llu", static_cast(t)); + } +}; + +template <> struct utest_type_deducer { + static void _(std::nullptr_t t) { + UTEST_PRINTF("%p", static_cast(t)); + } +}; + +template +UTEST_WEAK UTEST_OVERLOADABLE void utest_type_printer(const T t) { + utest_type_deducer::_(t); +} + +#ifdef __clang__ +#pragma clang diagnostic pop +#endif + +#elif defined(UTEST_OVERLOADABLE) + +UTEST_WEAK UTEST_OVERLOADABLE void utest_type_printer(signed char c); +UTEST_WEAK UTEST_OVERLOADABLE void utest_type_printer(signed char c) { + UTEST_PRINTF("%d", UTEST_CAST(int, c)); +} + +UTEST_WEAK UTEST_OVERLOADABLE void utest_type_printer(unsigned char c); +UTEST_WEAK UTEST_OVERLOADABLE void utest_type_printer(unsigned char c) { + UTEST_PRINTF("%u", UTEST_CAST(unsigned int, c)); +} + +UTEST_WEAK UTEST_OVERLOADABLE void utest_type_printer(float f); +UTEST_WEAK UTEST_OVERLOADABLE void utest_type_printer(float f) { + UTEST_PRINTF("%f", UTEST_CAST(double, f)); +} + +UTEST_WEAK UTEST_OVERLOADABLE void utest_type_printer(double d); +UTEST_WEAK UTEST_OVERLOADABLE void utest_type_printer(double d) { + UTEST_PRINTF("%f", d); +} + +UTEST_WEAK UTEST_OVERLOADABLE void utest_type_printer(long double d); +UTEST_WEAK UTEST_OVERLOADABLE void utest_type_printer(long double d) { +#if defined(__MINGW32__) || defined(__MINGW64__) + /* MINGW is weird - doesn't like LF at all?! */ + UTEST_PRINTF("%f", (double)d); +#else + UTEST_PRINTF("%Lf", d); +#endif +} + +UTEST_WEAK UTEST_OVERLOADABLE void utest_type_printer(int i); +UTEST_WEAK UTEST_OVERLOADABLE void utest_type_printer(int i) { + UTEST_PRINTF("%d", i); +} + +UTEST_WEAK UTEST_OVERLOADABLE void utest_type_printer(unsigned int i); +UTEST_WEAK UTEST_OVERLOADABLE void utest_type_printer(unsigned int i) { + UTEST_PRINTF("%u", i); +} + +UTEST_WEAK UTEST_OVERLOADABLE void utest_type_printer(long int i); +UTEST_WEAK UTEST_OVERLOADABLE void utest_type_printer(long int i) { + UTEST_PRINTF("%ld", i); +} + +UTEST_WEAK UTEST_OVERLOADABLE void utest_type_printer(long unsigned int i); +UTEST_WEAK UTEST_OVERLOADABLE void utest_type_printer(long unsigned int i) { + UTEST_PRINTF("%lu", i); +} + +UTEST_WEAK UTEST_OVERLOADABLE void utest_type_printer(const void *p); +UTEST_WEAK UTEST_OVERLOADABLE void utest_type_printer(const void *p) { + UTEST_PRINTF("%p", p); +} + +/* + long long is a c++11 extension +*/ +#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) || \ + defined(__cplusplus) && (__cplusplus >= 201103L) || \ + (defined(__MINGW32__) || defined(__MINGW64__)) + +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wc++98-compat-pedantic" +#endif + +UTEST_WEAK UTEST_OVERLOADABLE void utest_type_printer(long long int i); +UTEST_WEAK UTEST_OVERLOADABLE void utest_type_printer(long long int i) { + UTEST_PRINTF("%lld", i); +} + +UTEST_WEAK UTEST_OVERLOADABLE void utest_type_printer(long long unsigned int i); +UTEST_WEAK UTEST_OVERLOADABLE void +utest_type_printer(long long unsigned int i) { + UTEST_PRINTF("%llu", i); +} + +#ifdef __clang__ +#pragma clang diagnostic pop +#endif + +#endif +#elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L) && \ + !(defined(__MINGW32__) || defined(__MINGW64__)) || \ + defined(__TINYC__) +#define utest_type_printer(val) \ + UTEST_PRINTF(_Generic((val), signed char \ + : "%d", unsigned char \ + : "%u", short \ + : "%d", unsigned short \ + : "%u", int \ + : "%d", long \ + : "%ld", long long \ + : "%lld", unsigned \ + : "%u", unsigned long \ + : "%lu", unsigned long long \ + : "%llu", float \ + : "%f", double \ + : "%f", long double \ + : "%Lf", default \ + : _Generic((val - val), ptrdiff_t \ + : "%p", default \ + : "undef")), \ + (val)) +#else +/* + we don't have the ability to print the values we got, so we create a macro + to tell our users we can't do anything fancy +*/ +#define utest_type_printer(...) UTEST_PRINTF("undef") +#endif + +#if defined(_MSC_VER) +#define UTEST_SURPRESS_WARNING_BEGIN \ + __pragma(warning(push)) __pragma(warning(disable : 4127)) \ + __pragma(warning(disable : 4571)) __pragma(warning(disable : 4130)) +#define UTEST_SURPRESS_WARNING_END __pragma(warning(pop)) +#else +#define UTEST_SURPRESS_WARNING_BEGIN +#define UTEST_SURPRESS_WARNING_END +#endif + +#if defined(__cplusplus) && (__cplusplus >= 201103L) +#define UTEST_AUTO(x) auto +#elif !defined(__cplusplus) + +#if defined(__clang__) +/* clang-format off */ +/* had to disable clang-format here because it malforms the pragmas */ +#define UTEST_AUTO(x) \ + _Pragma("clang diagnostic push") \ + _Pragma("clang diagnostic ignored \"-Wgnu-auto-type\"") __auto_type \ + _Pragma("clang diagnostic pop") +/* clang-format on */ +#else +#define UTEST_AUTO(x) __typeof__(x + 0) +#endif + +#else +#define UTEST_AUTO(x) typeof(x + 0) +#endif + +#if defined(__clang__) +#define UTEST_STRNCMP(x, y, size) \ + _Pragma("clang diagnostic push") \ + _Pragma("clang diagnostic ignored \"-Wdisabled-macro-expansion\"") \ + strncmp(x, y, size) _Pragma("clang diagnostic pop") +#else +#define UTEST_STRNCMP(x, y, size) strncmp(x, y, size) +#endif + +#if defined(_MSC_VER) +#define UTEST_STRNCPY(x, y, size) strcpy_s(x, size, y) +#elif !defined(__clang__) && defined(__GNUC__) +static UTEST_INLINE char * +utest_strncpy_gcc(char *const dst, const char *const src, const size_t size) { +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wstringop-overflow" + return strncpy(dst, src, size); +#pragma GCC diagnostic pop +} + +#define UTEST_STRNCPY(x, y, size) utest_strncpy_gcc(x, y, size) +#else +#define UTEST_STRNCPY(x, y, size) strncpy(x, y, size) +#endif + +#define UTEST_SKIP(msg) \ + do { \ + UTEST_PRINTF(" Skipped : '%s'\n", (msg)); \ + *utest_result = UTEST_TEST_SKIPPED; \ + return; \ + } while (0) + +#if defined(__clang__) +#define UTEST_COND(x, y, cond, msg, is_assert) \ + UTEST_SURPRESS_WARNING_BEGIN do { \ + _Pragma("clang diagnostic push") \ + _Pragma("clang diagnostic ignored \"-Wlanguage-extension-token\"") \ + _Pragma("clang diagnostic ignored \"-Wc++98-compat-pedantic\"") \ + _Pragma("clang diagnostic ignored \"-Wfloat-equal\"") \ + UTEST_AUTO(x) xEval = (x); \ + UTEST_AUTO(y) yEval = (y); \ + if (!((xEval)cond(yEval))) { \ + const char *const xAsString = #x; \ + const char *const yAsString = #y; \ + _Pragma("clang diagnostic pop") \ + UTEST_PRINTF("%s:%i: Failure\n", __FILE__, __LINE__); \ + UTEST_PRINTF(" Expected : ("); \ + UTEST_PRINTF("%s) " #cond " (%s", xAsString, yAsString); \ + UTEST_PRINTF(")\n"); \ + UTEST_PRINTF(" Actual : "); \ + utest_type_printer(xEval); \ + UTEST_PRINTF(" vs "); \ + utest_type_printer(yEval); \ + UTEST_PRINTF("\n"); \ + if (strlen(msg) > 0) { \ + UTEST_PRINTF(" Message : %s\n", msg); \ + } \ + *utest_result = UTEST_TEST_FAILURE; \ + if (is_assert) { \ + return; \ + } \ + } \ + } \ + while (0) \ + UTEST_SURPRESS_WARNING_END +#elif defined(__GNUC__) || defined(__TINYC__) +#define UTEST_COND(x, y, cond, msg, is_assert) \ + UTEST_SURPRESS_WARNING_BEGIN do { \ + UTEST_AUTO(x) xEval = (x); \ + UTEST_AUTO(y) yEval = (y); \ + if (!((xEval)cond(yEval))) { \ + const char *const xAsString = #x; \ + const char *const yAsString = #y; \ + UTEST_PRINTF("%s:%i: Failure\n", __FILE__, __LINE__); \ + UTEST_PRINTF(" Expected : ("); \ + UTEST_PRINTF("%s) " #cond " (%s", xAsString, yAsString); \ + UTEST_PRINTF(")\n"); \ + UTEST_PRINTF(" Actual : "); \ + utest_type_printer(xEval); \ + UTEST_PRINTF(" vs "); \ + utest_type_printer(yEval); \ + UTEST_PRINTF("\n"); \ + if (strlen(msg) > 0) { \ + UTEST_PRINTF(" Message : %s\n", msg); \ + } \ + *utest_result = UTEST_TEST_FAILURE; \ + if (is_assert) { \ + return; \ + } \ + } \ + } \ + while (0) \ + UTEST_SURPRESS_WARNING_END +#else +#define UTEST_COND(x, y, cond, msg, is_assert) \ + UTEST_SURPRESS_WARNING_BEGIN do { \ + if (!((x)cond(y))) { \ + UTEST_PRINTF("%s:%i: Failure (Expected " #cond " Actual)", __FILE__, \ + __LINE__); \ + if (strlen(msg) > 0) { \ + UTEST_PRINTF(" Message : %s", msg); \ + } \ + UTEST_PRINTF("\n"); \ + *utest_result = UTEST_TEST_FAILURE; \ + if (is_assert) { \ + return; \ + } \ + } \ + } \ + while (0) \ + UTEST_SURPRESS_WARNING_END +#endif + +#define EXPECT_EQ(x, y) UTEST_COND(x, y, ==, "", 0) +#define EXPECT_EQ_MSG(x, y, msg) UTEST_COND(x, y, ==, msg, 0) +#define ASSERT_EQ(x, y) UTEST_COND(x, y, ==, "", 1) +#define ASSERT_EQ_MSG(x, y, msg) UTEST_COND(x, y, ==, msg, 1) + +#define EXPECT_NE(x, y) UTEST_COND(x, y, !=, "", 0) +#define EXPECT_NE_MSG(x, y, msg) UTEST_COND(x, y, !=, msg, 0) +#define ASSERT_NE(x, y) UTEST_COND(x, y, !=, "", 1) +#define ASSERT_NE_MSG(x, y, msg) UTEST_COND(x, y, !=, msg, 1) + +#define EXPECT_LT(x, y) UTEST_COND(x, y, <, "", 0) +#define EXPECT_LT_MSG(x, y, msg) UTEST_COND(x, y, <, msg, 0) +#define ASSERT_LT(x, y) UTEST_COND(x, y, <, "", 1) +#define ASSERT_LT_MSG(x, y, msg) UTEST_COND(x, y, <, msg, 1) + +#define EXPECT_LE(x, y) UTEST_COND(x, y, <=, "", 0) +#define EXPECT_LE_MSG(x, y, msg) UTEST_COND(x, y, <=, msg, 0) +#define ASSERT_LE(x, y) UTEST_COND(x, y, <=, "", 1) +#define ASSERT_LE_MSG(x, y, msg) UTEST_COND(x, y, <=, msg, 1) + +#define EXPECT_GT(x, y) UTEST_COND(x, y, >, "", 0) +#define EXPECT_GT_MSG(x, y, msg) UTEST_COND(x, y, >, msg, 0) +#define ASSERT_GT(x, y) UTEST_COND(x, y, >, "", 1) +#define ASSERT_GT_MSG(x, y, msg) UTEST_COND(x, y, >, msg, 1) + +#define EXPECT_GE(x, y) UTEST_COND(x, y, >=, "", 0) +#define EXPECT_GE_MSG(x, y, msg) UTEST_COND(x, y, >=, msg, 0) +#define ASSERT_GE(x, y) UTEST_COND(x, y, >=, "", 1) +#define ASSERT_GE_MSG(x, y, msg) UTEST_COND(x, y, >=, msg, 1) + +#define UTEST_TRUE(x, msg, is_assert) \ + UTEST_SURPRESS_WARNING_BEGIN do { \ + const int xEval = !!(x); \ + if (!(xEval)) { \ + UTEST_PRINTF("%s:%i: Failure\n", __FILE__, __LINE__); \ + UTEST_PRINTF(" Expected : true\n"); \ + UTEST_PRINTF(" Actual : %s\n", (xEval) ? "true" : "false"); \ + if (strlen(msg) > 0) { \ + UTEST_PRINTF(" Message : %s\n", msg); \ + } \ + *utest_result = UTEST_TEST_FAILURE; \ + if (is_assert) { \ + return; \ + } \ + } \ + } \ + while (0) \ + UTEST_SURPRESS_WARNING_END + +#define EXPECT_TRUE(x) UTEST_TRUE(x, "", 0) +#define EXPECT_TRUE_MSG(x, msg) UTEST_TRUE(x, msg, 0) +#define ASSERT_TRUE(x) UTEST_TRUE(x, "", 1) +#define ASSERT_TRUE_MSG(x, msg) UTEST_TRUE(x, msg, 1) + +#define UTEST_FALSE(x, msg, is_assert) \ + UTEST_SURPRESS_WARNING_BEGIN do { \ + const int xEval = !!(x); \ + if (xEval) { \ + UTEST_PRINTF("%s:%i: Failure\n", __FILE__, __LINE__); \ + UTEST_PRINTF(" Expected : false\n"); \ + UTEST_PRINTF(" Actual : %s\n", (xEval) ? "true" : "false"); \ + if (strlen(msg) > 0) { \ + UTEST_PRINTF(" Message : %s\n", msg); \ + } \ + *utest_result = UTEST_TEST_FAILURE; \ + if (is_assert) { \ + return; \ + } \ + } \ + } \ + while (0) \ + UTEST_SURPRESS_WARNING_END + +#define EXPECT_FALSE(x) UTEST_FALSE(x, "", 0) +#define EXPECT_FALSE_MSG(x, msg) UTEST_FALSE(x, msg, 0) +#define ASSERT_FALSE(x) UTEST_FALSE(x, "", 1) +#define ASSERT_FALSE_MSG(x, msg) UTEST_FALSE(x, msg, 1) + +#define UTEST_STREQ(x, y, msg, is_assert) \ + UTEST_SURPRESS_WARNING_BEGIN do { \ + const char *xEval = (x); \ + const char *yEval = (y); \ + if (UTEST_NULL == xEval || UTEST_NULL == yEval || \ + 0 != strcmp(xEval, yEval)) { \ + UTEST_PRINTF("%s:%i: Failure\n", __FILE__, __LINE__); \ + UTEST_PRINTF(" Expected : \"%s\"\n", xEval); \ + UTEST_PRINTF(" Actual : \"%s\"\n", yEval); \ + if (strlen(msg) > 0) { \ + UTEST_PRINTF(" Message : %s\n", msg); \ + } \ + *utest_result = UTEST_TEST_FAILURE; \ + if (is_assert) { \ + return; \ + } \ + } \ + } \ + while (0) \ + UTEST_SURPRESS_WARNING_END + +#define EXPECT_STREQ(x, y) UTEST_STREQ(x, y, "", 0) +#define EXPECT_STREQ_MSG(x, y, msg) UTEST_STREQ(x, y, msg, 0) +#define ASSERT_STREQ(x, y) UTEST_STREQ(x, y, "", 1) +#define ASSERT_STREQ_MSG(x, y, msg) UTEST_STREQ(x, y, msg, 1) + +#define UTEST_STRNE(x, y, msg, is_assert) \ + UTEST_SURPRESS_WARNING_BEGIN do { \ + const char *xEval = (x); \ + const char *yEval = (y); \ + if (UTEST_NULL == xEval || UTEST_NULL == yEval || \ + 0 == strcmp(xEval, yEval)) { \ + UTEST_PRINTF("%s:%i: Failure\n", __FILE__, __LINE__); \ + UTEST_PRINTF(" Expected : \"%s\"\n", xEval); \ + UTEST_PRINTF(" Actual : \"%s\"\n", yEval); \ + if (strlen(msg) > 0) { \ + UTEST_PRINTF(" Message : %s\n", msg); \ + } \ + *utest_result = UTEST_TEST_FAILURE; \ + if (is_assert) { \ + return; \ + } \ + } \ + } \ + while (0) \ + UTEST_SURPRESS_WARNING_END + +#define EXPECT_STRNE(x, y) UTEST_STRNE(x, y, "", 0) +#define EXPECT_STRNE_MSG(x, y, msg) UTEST_STRNE(x, y, msg, 0) +#define ASSERT_STRNE(x, y) UTEST_STRNE(x, y, "", 1) +#define ASSERT_STRNE_MSG(x, y, msg) UTEST_STRNE(x, y, msg, 1) + +#define UTEST_STRNEQ(x, y, n, msg, is_assert) \ + UTEST_SURPRESS_WARNING_BEGIN do { \ + const char *xEval = (x); \ + const char *yEval = (y); \ + const size_t nEval = UTEST_CAST(size_t, n); \ + if (UTEST_NULL == xEval || UTEST_NULL == yEval || \ + 0 != UTEST_STRNCMP(xEval, yEval, nEval)) { \ + UTEST_PRINTF("%s:%i: Failure\n", __FILE__, __LINE__); \ + UTEST_PRINTF(" Expected : \"%.*s\"\n", UTEST_CAST(int, nEval), xEval); \ + UTEST_PRINTF(" Actual : \"%.*s\"\n", UTEST_CAST(int, nEval), yEval); \ + if (strlen(msg) > 0) { \ + UTEST_PRINTF(" Message : %s\n", msg); \ + } \ + *utest_result = UTEST_TEST_FAILURE; \ + if (is_assert) { \ + return; \ + } \ + } \ + } \ + while (0) \ + UTEST_SURPRESS_WARNING_END + +#define EXPECT_STRNEQ(x, y, n) UTEST_STRNEQ(x, y, n, "", 0) +#define EXPECT_STRNEQ_MSG(x, y, n, msg) UTEST_STRNEQ(x, y, n, msg, 0) +#define ASSERT_STRNEQ(x, y, n) UTEST_STRNEQ(x, y, n, "", 1) +#define ASSERT_STRNEQ_MSG(x, y, n, msg) UTEST_STRNEQ(x, y, n, msg, 1) + +#define UTEST_STRNNE(x, y, n, msg, is_assert) \ + UTEST_SURPRESS_WARNING_BEGIN do { \ + const char *xEval = (x); \ + const char *yEval = (y); \ + const size_t nEval = UTEST_CAST(size_t, n); \ + if (UTEST_NULL == xEval || UTEST_NULL == yEval || \ + 0 == UTEST_STRNCMP(xEval, yEval, nEval)) { \ + UTEST_PRINTF("%s:%i: Failure\n", __FILE__, __LINE__); \ + UTEST_PRINTF(" Expected : \"%.*s\"\n", UTEST_CAST(int, nEval), xEval); \ + UTEST_PRINTF(" Actual : \"%.*s\"\n", UTEST_CAST(int, nEval), yEval); \ + if (strlen(msg) > 0) { \ + UTEST_PRINTF(" Message : %s\n", msg); \ + } \ + *utest_result = UTEST_TEST_FAILURE; \ + if (is_assert) { \ + return; \ + } \ + } \ + } \ + while (0) \ + UTEST_SURPRESS_WARNING_END + +#define EXPECT_STRNNE(x, y, n) UTEST_STRNNE(x, y, n, "", 0) +#define EXPECT_STRNNE_MSG(x, y, n, msg) UTEST_STRNNE(x, y, n, msg, 0) +#define ASSERT_STRNNE(x, y, n) UTEST_STRNNE(x, y, n, "", 1) +#define ASSERT_STRNNE_MSG(x, y, n, msg) UTEST_STRNNE(x, y, n, msg, 1) + +#define UTEST_NEAR(x, y, epsilon, msg, is_assert) \ + UTEST_SURPRESS_WARNING_BEGIN do { \ + const double diff = \ + utest_fabs(UTEST_CAST(double, x) - UTEST_CAST(double, y)); \ + if (diff > UTEST_CAST(double, epsilon) || utest_isnan(diff)) { \ + UTEST_PRINTF("%s:%i: Failure\n", __FILE__, __LINE__); \ + UTEST_PRINTF(" Expected : %f\n", UTEST_CAST(double, x)); \ + UTEST_PRINTF(" Actual : %f\n", UTEST_CAST(double, y)); \ + if (strlen(msg) > 0) { \ + UTEST_PRINTF(" Message : %s\n", msg); \ + } \ + *utest_result = UTEST_TEST_FAILURE; \ + if (is_assert) { \ + return; \ + } \ + } \ + } \ + while (0) \ + UTEST_SURPRESS_WARNING_END + +#define EXPECT_NEAR(x, y, epsilon) UTEST_NEAR(x, y, epsilon, "", 0) +#define EXPECT_NEAR_MSG(x, y, epsilon, msg) UTEST_NEAR(x, y, epsilon, msg, 0) +#define ASSERT_NEAR(x, y, epsilon) UTEST_NEAR(x, y, epsilon, "", 1) +#define ASSERT_NEAR_MSG(x, y, epsilon, msg) UTEST_NEAR(x, y, epsilon, msg, 1) + +#if defined(UTEST_HAS_EXCEPTIONS) +#define UTEST_EXCEPTION(x, exception_type, msg, is_assert) \ + UTEST_SURPRESS_WARNING_BEGIN do { \ + int exception_caught = 0; \ + try { \ + x; \ + } catch (const exception_type &) { \ + exception_caught = 1; \ + } catch (...) { \ + exception_caught = 2; \ + } \ + if (1 != exception_caught) { \ + UTEST_PRINTF("%s:%i: Failure\n", __FILE__, __LINE__); \ + UTEST_PRINTF(" Expected : %s exception\n", #exception_type); \ + UTEST_PRINTF(" Actual : %s\n", (2 == exception_caught) \ + ? "Unexpected exception" \ + : "No exception"); \ + if (strlen(msg) > 0) { \ + UTEST_PRINTF(" Message : %s\n", msg); \ + } \ + *utest_result = UTEST_TEST_FAILURE; \ + if (is_assert) { \ + return; \ + } \ + } \ + } \ + while (0) \ + UTEST_SURPRESS_WARNING_END + +#define EXPECT_EXCEPTION(x, exception_type) \ + UTEST_EXCEPTION(x, exception_type, "", 0) +#define EXPECT_EXCEPTION_MSG(x, exception_type, msg) \ + UTEST_EXCEPTION(x, exception_type, msg, 0) +#define ASSERT_EXCEPTION(x, exception_type) \ + UTEST_EXCEPTION(x, exception_type, "", 1) +#define ASSERT_EXCEPTION_MSG(x, exception_type, msg) \ + UTEST_EXCEPTION(x, exception_type, msg, 1) + +#define UTEST_EXCEPTION_WITH_MESSAGE(x, exception_type, exception_message, \ + msg, is_assert) \ + UTEST_SURPRESS_WARNING_BEGIN do { \ + int exception_caught = 0; \ + char *message_caught = UTEST_NULL; \ + try { \ + x; \ + } catch (const exception_type &e) { \ + const char *const what = e.what(); \ + exception_caught = 1; \ + if (0 != \ + UTEST_STRNCMP(what, exception_message, strlen(exception_message))) { \ + const size_t message_size = strlen(what) + 1; \ + message_caught = UTEST_PTR_CAST(char *, malloc(message_size)); \ + UTEST_STRNCPY(message_caught, what, message_size); \ + } \ + } catch (...) { \ + exception_caught = 2; \ + } \ + if (1 != exception_caught) { \ + UTEST_PRINTF("%s:%i: Failure\n", __FILE__, __LINE__); \ + UTEST_PRINTF(" Expected : %s exception\n", #exception_type); \ + UTEST_PRINTF(" Actual : %s\n", (2 == exception_caught) \ + ? "Unexpected exception" \ + : "No exception"); \ + if (strlen(msg) > 0) { \ + UTEST_PRINTF(" Message : %s\n", msg); \ + } \ + *utest_result = UTEST_TEST_FAILURE; \ + if (is_assert) { \ + return; \ + } \ + } else if (UTEST_NULL != message_caught) { \ + UTEST_PRINTF("%s:%i: Failure\n", __FILE__, __LINE__); \ + UTEST_PRINTF(" Expected : %s exception with message %s\n", \ + #exception_type, exception_message); \ + UTEST_PRINTF(" Actual message : %s\n", message_caught); \ + if (strlen(msg) > 0) { \ + UTEST_PRINTF(" Message : %s\n", msg); \ + } \ + *utest_result = UTEST_TEST_FAILURE; \ + free(message_caught); \ + if (is_assert) { \ + return; \ + } \ + } \ + } \ + while (0) \ + UTEST_SURPRESS_WARNING_END + +#define EXPECT_EXCEPTION_WITH_MESSAGE(x, exception_type, exception_message) \ + UTEST_EXCEPTION_WITH_MESSAGE(x, exception_type, exception_message, "", 0) +#define EXPECT_EXCEPTION_WITH_MESSAGE_MSG(x, exception_type, \ + exception_message, msg) \ + UTEST_EXCEPTION_WITH_MESSAGE(x, exception_type, exception_message, msg, 0) +#define ASSERT_EXCEPTION_WITH_MESSAGE(x, exception_type, exception_message) \ + UTEST_EXCEPTION_WITH_MESSAGE(x, exception_type, exception_message, "", 1) +#define ASSERT_EXCEPTION_WITH_MESSAGE_MSG(x, exception_type, \ + exception_message, msg) \ + UTEST_EXCEPTION_WITH_MESSAGE(x, exception_type, exception_message, msg, 1) +#endif + +#if defined(__clang__) +#if __has_warning("-Wunsafe-buffer-usage") +#define UTEST_SURPRESS_WARNINGS_BEGIN \ + _Pragma("clang diagnostic push") \ + _Pragma("clang diagnostic ignored \"-Wunsafe-buffer-usage\"") +#define UTEST_SURPRESS_WARNINGS_END _Pragma("clang diagnostic pop") +#else +#define UTEST_SURPRESS_WARNINGS_BEGIN +#define UTEST_SURPRESS_WARNINGS_END +#endif +#elif defined(__GNUC__) && __GNUC__ >= 8 && defined(__cplusplus) +#define UTEST_SURPRESS_WARNINGS_BEGIN \ + _Pragma("GCC diagnostic push") \ + _Pragma("GCC diagnostic ignored \"-Wclass-memaccess\"") +#define UTEST_SURPRESS_WARNINGS_END _Pragma("GCC diagnostic pop") +#else +#define UTEST_SURPRESS_WARNINGS_BEGIN +#define UTEST_SURPRESS_WARNINGS_END +#endif + +#define UTEST(SET, NAME) \ + UTEST_SURPRESS_WARNINGS_BEGIN \ + UTEST_EXTERN struct utest_state_s utest_state; \ + static void utest_run_##SET##_##NAME(int *utest_result); \ + static void utest_##SET##_##NAME(int *utest_result, size_t utest_index) { \ + (void)utest_index; \ + utest_run_##SET##_##NAME(utest_result); \ + } \ + UTEST_INITIALIZER(utest_register_##SET##_##NAME) { \ + const size_t index = utest_state.tests_length++; \ + const char name_part[] = #SET "." #NAME; \ + const size_t name_size = strlen(name_part) + 1; \ + char *name = UTEST_PTR_CAST(char *, malloc(name_size)); \ + utest_state.tests = UTEST_PTR_CAST( \ + struct utest_test_state_s *, \ + utest_realloc(UTEST_PTR_CAST(void *, utest_state.tests), \ + sizeof(struct utest_test_state_s) * \ + utest_state.tests_length)); \ + if (utest_state.tests && name) { \ + utest_state.tests[index].func = &utest_##SET##_##NAME; \ + utest_state.tests[index].name = name; \ + utest_state.tests[index].index = 0; \ + UTEST_SNPRINTF(name, name_size, "%s", name_part); \ + } else { \ + if (utest_state.tests) { \ + free(utest_state.tests); \ + utest_state.tests = NULL; \ + } \ + if (name) { \ + free(name); \ + } \ + } \ + } \ + UTEST_SURPRESS_WARNINGS_END \ + void utest_run_##SET##_##NAME(int *utest_result) + +#define UTEST_F_SETUP(FIXTURE) \ + static void utest_f_setup_##FIXTURE(int *utest_result, \ + struct FIXTURE *utest_fixture) + +#define UTEST_F_TEARDOWN(FIXTURE) \ + static void utest_f_teardown_##FIXTURE(int *utest_result, \ + struct FIXTURE *utest_fixture) + +#define UTEST_F(FIXTURE, NAME) \ + UTEST_SURPRESS_WARNINGS_BEGIN \ + UTEST_EXTERN struct utest_state_s utest_state; \ + static void utest_f_setup_##FIXTURE(int *, struct FIXTURE *); \ + static void utest_f_teardown_##FIXTURE(int *, struct FIXTURE *); \ + static void utest_run_##FIXTURE##_##NAME(int *, struct FIXTURE *); \ + static void utest_f_##FIXTURE##_##NAME(int *utest_result, \ + size_t utest_index) { \ + struct FIXTURE fixture; \ + (void)utest_index; \ + memset(&fixture, 0, sizeof(fixture)); \ + utest_f_setup_##FIXTURE(utest_result, &fixture); \ + if (UTEST_TEST_PASSED != *utest_result) { \ + return; \ + } \ + utest_run_##FIXTURE##_##NAME(utest_result, &fixture); \ + utest_f_teardown_##FIXTURE(utest_result, &fixture); \ + } \ + UTEST_INITIALIZER(utest_register_##FIXTURE##_##NAME) { \ + const size_t index = utest_state.tests_length++; \ + const char name_part[] = #FIXTURE "." #NAME; \ + const size_t name_size = strlen(name_part) + 1; \ + char *name = UTEST_PTR_CAST(char *, malloc(name_size)); \ + utest_state.tests = UTEST_PTR_CAST( \ + struct utest_test_state_s *, \ + utest_realloc(UTEST_PTR_CAST(void *, utest_state.tests), \ + sizeof(struct utest_test_state_s) * \ + utest_state.tests_length)); \ + if (utest_state.tests && name) { \ + utest_state.tests[index].func = &utest_f_##FIXTURE##_##NAME; \ + utest_state.tests[index].name = name; \ + UTEST_SNPRINTF(name, name_size, "%s", name_part); \ + } else { \ + if (utest_state.tests) { \ + free(utest_state.tests); \ + utest_state.tests = NULL; \ + } \ + if (name) { \ + free(name); \ + } \ + } \ + } \ + UTEST_SURPRESS_WARNINGS_END \ + void utest_run_##FIXTURE##_##NAME(int *utest_result, \ + struct FIXTURE *utest_fixture) + +#define UTEST_I_SETUP(FIXTURE) \ + static void utest_i_setup_##FIXTURE( \ + int *utest_result, struct FIXTURE *utest_fixture, size_t utest_index) + +#define UTEST_I_TEARDOWN(FIXTURE) \ + static void utest_i_teardown_##FIXTURE( \ + int *utest_result, struct FIXTURE *utest_fixture, size_t utest_index) + +#define UTEST_I(FIXTURE, NAME, INDEX) \ + UTEST_SURPRESS_WARNINGS_BEGIN \ + UTEST_EXTERN struct utest_state_s utest_state; \ + static void utest_run_##FIXTURE##_##NAME##_##INDEX(int *, struct FIXTURE *); \ + static void utest_i_##FIXTURE##_##NAME##_##INDEX(int *utest_result, \ + size_t index) { \ + struct FIXTURE fixture; \ + memset(&fixture, 0, sizeof(fixture)); \ + utest_i_setup_##FIXTURE(utest_result, &fixture, index); \ + if (UTEST_TEST_PASSED != *utest_result) { \ + return; \ + } \ + utest_run_##FIXTURE##_##NAME##_##INDEX(utest_result, &fixture); \ + utest_i_teardown_##FIXTURE(utest_result, &fixture, index); \ + } \ + UTEST_INITIALIZER(utest_register_##FIXTURE##_##NAME##_##INDEX) { \ + size_t i; \ + utest_uint64_t iUp; \ + for (i = 0; i < (INDEX); i++) { \ + const size_t index = utest_state.tests_length++; \ + const char name_part[] = #FIXTURE "." #NAME; \ + const size_t name_size = strlen(name_part) + 32; \ + char *name = UTEST_PTR_CAST(char *, malloc(name_size)); \ + utest_state.tests = UTEST_PTR_CAST( \ + struct utest_test_state_s *, \ + utest_realloc(UTEST_PTR_CAST(void *, utest_state.tests), \ + sizeof(struct utest_test_state_s) * \ + utest_state.tests_length)); \ + if (utest_state.tests && name) { \ + utest_state.tests[index].func = &utest_i_##FIXTURE##_##NAME##_##INDEX; \ + utest_state.tests[index].index = i; \ + utest_state.tests[index].name = name; \ + iUp = UTEST_CAST(utest_uint64_t, i); \ + UTEST_SNPRINTF(name, name_size, "%s/%" UTEST_PRIu64, name_part, iUp); \ + } else { \ + if (utest_state.tests) { \ + free(utest_state.tests); \ + utest_state.tests = NULL; \ + } \ + if (name) { \ + free(name); \ + } \ + } \ + } \ + } \ + UTEST_SURPRESS_WARNINGS_END \ + void utest_run_##FIXTURE##_##NAME##_##INDEX(int *utest_result, \ + struct FIXTURE *utest_fixture) + +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wc++98-compat-pedantic" +#endif + +UTEST_WEAK +double utest_fabs(double d); +UTEST_WEAK +double utest_fabs(double d) { + union { + double d; + utest_uint64_t u; + } both; + both.d = d; + both.u &= 0x7fffffffffffffffu; + return both.d; +} + +UTEST_WEAK +int utest_isnan(double d); +UTEST_WEAK +int utest_isnan(double d) { + union { + double d; + utest_uint64_t u; + } both; + both.d = d; + both.u &= 0x7fffffffffffffffu; + return both.u > 0x7ff0000000000000u; +} + +#ifdef __clang__ +#pragma clang diagnostic pop +#endif + +#if defined(__clang__) +#if __has_warning("-Wunsafe-buffer-usage") +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wunsafe-buffer-usage" +#endif +#endif + +UTEST_WEAK +int utest_should_filter_test(const char *filter, const char *testcase); +UTEST_WEAK int utest_should_filter_test(const char *filter, + const char *testcase) { + if (filter) { + const char *filter_cur = filter; + const char *testcase_cur = testcase; + const char *filter_wildcard = UTEST_NULL; + + while (('\0' != *filter_cur) && ('\0' != *testcase_cur)) { + if ('*' == *filter_cur) { + /* store the position of the wildcard */ + filter_wildcard = filter_cur; + + /* skip the wildcard character */ + filter_cur++; + + while (('\0' != *filter_cur) && ('\0' != *testcase_cur)) { + if ('*' == *filter_cur) { + /* + we found another wildcard (filter is something like *foo*) so we + exit the current loop, and return to the parent loop to handle + the wildcard case + */ + break; + } else if (*filter_cur != *testcase_cur) { + /* otherwise our filter didn't match, so reset it */ + filter_cur = filter_wildcard; + } + + /* move testcase along */ + testcase_cur++; + + /* move filter along */ + filter_cur++; + } + + if (('\0' == *filter_cur) && ('\0' == *testcase_cur)) { + return 0; + } + + /* if the testcase has been exhausted, we don't have a match! */ + if ('\0' == *testcase_cur) { + return 1; + } + } else { + if (*testcase_cur != *filter_cur) { + /* test case doesn't match filter */ + return 1; + } else { + /* move our filter and testcase forward */ + testcase_cur++; + filter_cur++; + } + } + } + + if (('\0' != *filter_cur) || + (('\0' != *testcase_cur) && + ((filter == filter_cur) || ('*' != filter_cur[-1])))) { + /* we have a mismatch! */ + return 1; + } + } + + return 0; +} + +static UTEST_INLINE FILE *utest_fopen(const char *filename, const char *mode) { +#ifdef _MSC_VER + FILE *file; + if (0 == fopen_s(&file, filename, mode)) { + return file; + } else { + return UTEST_NULL; + } +#else + return fopen(filename, mode); +#endif +} + +static UTEST_INLINE int utest_main(int argc, const char *const argv[]); +int utest_main(int argc, const char *const argv[]) { + utest_uint64_t failed = 0; + utest_uint64_t skipped = 0; + size_t index = 0; + size_t *failed_testcases = UTEST_NULL; + size_t failed_testcases_length = 0; + size_t *skipped_testcases = UTEST_NULL; + size_t skipped_testcases_length = 0; + const char *filter = UTEST_NULL; + utest_uint64_t ran_tests = 0; + int enable_mixed_units = 0; + int random_order = 0; + utest_uint32_t seed = 0; + + enum colours { RESET, GREEN, RED, YELLOW }; + + const int use_colours = UTEST_COLOUR_OUTPUT(); + const char *colours[] = {"\033[0m", "\033[32m", "\033[31m", "\033[33m"}; + + if (!use_colours) { + for (index = 0; index < sizeof colours / sizeof colours[0]; index++) { + colours[index] = ""; + } + } + /* loop through all arguments looking for our options */ + for (index = 1; index < UTEST_CAST(size_t, argc); index++) { + /* Informational switches */ + const char help_str[] = "--help"; + const char list_str[] = "--list-tests"; + /* Test config switches */ + const char filter_str[] = "--filter="; + const char output_str[] = "--output="; + const char enable_mixed_units_str[] = "--enable-mixed-units"; + const char random_order_str[] = "--random-order"; + const char random_order_with_seed_str[] = "--random-order="; + + if (0 == UTEST_STRNCMP(argv[index], help_str, strlen(help_str))) { + printf("utest.h - the single file unit testing solution for C/C++!\n" + "Command line Options:\n" + " --help Show this message and exit.\n" + " --filter= Filter the test cases to run (EG. " + "MyTest*.a would run MyTestCase.a but not MyTestCase.b).\n" + " --list-tests List testnames, one per line. Output " + "names can be passed to --filter.\n"); + printf(" --output= Output an xunit XML file to the file " + "specified in .\n" + " --enable-mixed-units Enable the per-test output to contain " + "mixed units (s/ms/us/ns).\n" + " --random-order[=] Randomize the order that the tests are " + "ran in. If the optional argument is not provided, then a " + "random starting seed is used.\n"); + goto cleanup; + } else if (0 == + UTEST_STRNCMP(argv[index], filter_str, strlen(filter_str))) { + /* user wants to filter what test cases run! */ + filter = argv[index] + strlen(filter_str); + } else if (0 == + UTEST_STRNCMP(argv[index], output_str, strlen(output_str))) { + utest_state.output = utest_fopen(argv[index] + strlen(output_str), "w+"); + } else if (0 == UTEST_STRNCMP(argv[index], list_str, strlen(list_str))) { + for (index = 0; index < utest_state.tests_length; index++) { + UTEST_PRINTF("%s\n", utest_state.tests[index].name); + } + /* when printing the test list, don't actually run the tests */ + return 0; + } else if (0 == UTEST_STRNCMP(argv[index], enable_mixed_units_str, + strlen(enable_mixed_units_str))) { + enable_mixed_units = 1; + } else if (0 == UTEST_STRNCMP(argv[index], random_order_with_seed_str, + strlen(random_order_with_seed_str))) { + seed = + UTEST_CAST(utest_uint32_t, + strtoul(argv[index] + strlen(random_order_with_seed_str), + UTEST_NULL, 10)); + random_order = 1; + } else if (0 == UTEST_STRNCMP(argv[index], random_order_str, + strlen(random_order_str))) { + const utest_int64_t ns = utest_ns(); + + // Some really poor pseudo-random using the current time. I do this + // because I really want to avoid using C's rand() because that'd mean our + // random would be affected by any srand() usage by the user (which I + // don't want). + seed = UTEST_CAST(utest_uint32_t, ns >> 32) * 31 + + UTEST_CAST(utest_uint32_t, ns & 0xffffffff); + random_order = 1; + } + } + + if (random_order) { + // Use Fisher-Yates with the Durstenfield's version to randomly re-order the + // tests. + for (index = utest_state.tests_length; index > 1; index--) { + // For the random order we'll use PCG. + const utest_uint32_t state = seed; + const utest_uint32_t word = + ((state >> ((state >> 28u) + 4u)) ^ state) * 277803737u; + const utest_uint32_t next = + ((word >> 22u) ^ word) % UTEST_CAST(utest_uint32_t, index); + + // Swap the randomly chosen element into the last location. + const struct utest_test_state_s copy = utest_state.tests[index - 1]; + utest_state.tests[index - 1] = utest_state.tests[next]; + utest_state.tests[next] = copy; + + // Move the seed onwards. + seed = seed * 747796405u + 2891336453u; + } + } + + for (index = 0; index < utest_state.tests_length; index++) { + if (utest_should_filter_test(filter, utest_state.tests[index].name)) { + continue; + } + + ran_tests++; + } + + printf("%s[==========]%s Running %" UTEST_PRIu64 " test cases.\n", + colours[GREEN], colours[RESET], UTEST_CAST(utest_uint64_t, ran_tests)); + + if (utest_state.output) { + fprintf(utest_state.output, "\n"); + fprintf(utest_state.output, + "\n", + UTEST_CAST(utest_uint64_t, ran_tests)); + fprintf(utest_state.output, + "\n", + UTEST_CAST(utest_uint64_t, ran_tests)); + } + + for (index = 0; index < utest_state.tests_length; index++) { + int result = UTEST_TEST_PASSED; + utest_int64_t ns = 0; + + if (utest_should_filter_test(filter, utest_state.tests[index].name)) { + continue; + } + + printf("%s[ RUN ]%s %s\n", colours[GREEN], colours[RESET], + utest_state.tests[index].name); + + if (utest_state.output) { + fprintf(utest_state.output, "", + utest_state.tests[index].name); + } + + ns = utest_ns(); + errno = 0; +#if defined(UTEST_HAS_EXCEPTIONS) + UTEST_SURPRESS_WARNING_BEGIN + try { + utest_state.tests[index].func(&result, utest_state.tests[index].index); + } catch (const std::exception &err) { + printf(" Exception : %s\n", err.what()); + result = UTEST_TEST_FAILURE; + } catch (...) { + printf(" Exception : Unknown\n"); + result = UTEST_TEST_FAILURE; + } + UTEST_SURPRESS_WARNING_END +#else + utest_state.tests[index].func(&result, utest_state.tests[index].index); +#endif + ns = utest_ns() - ns; + + if (utest_state.output) { + fprintf(utest_state.output, "\n"); + } + + // Record the failing test. + if (UTEST_TEST_FAILURE == result) { + const size_t failed_testcase_index = failed_testcases_length++; + failed_testcases = UTEST_PTR_CAST( + size_t *, utest_realloc(UTEST_PTR_CAST(void *, failed_testcases), + sizeof(size_t) * failed_testcases_length)); + if (UTEST_NULL != failed_testcases) { + failed_testcases[failed_testcase_index] = index; + } + failed++; + } else if (UTEST_TEST_SKIPPED == result) { + const size_t skipped_testcase_index = skipped_testcases_length++; + skipped_testcases = UTEST_PTR_CAST( + size_t *, utest_realloc(UTEST_PTR_CAST(void *, skipped_testcases), + sizeof(size_t) * skipped_testcases_length)); + if (UTEST_NULL != skipped_testcases) { + skipped_testcases[skipped_testcase_index] = index; + } + skipped++; + } + + { + const char *const units[] = {"ns", "us", "ms", "s", UTEST_NULL}; + unsigned int unit_index = 0; + utest_int64_t time = ns; + + if (enable_mixed_units) { + for (unit_index = 0; UTEST_NULL != units[unit_index]; unit_index++) { + if (10000 > time) { + break; + } + + time /= 1000; + } + } + + if (UTEST_TEST_FAILURE == result) { + printf("%s[ FAILED ]%s %s (%" UTEST_PRId64 "%s)\n", colours[RED], + colours[RESET], utest_state.tests[index].name, time, + units[unit_index]); + } else if (UTEST_TEST_SKIPPED == result) { + printf("%s[ SKIPPED ]%s %s (%" UTEST_PRId64 "%s)\n", colours[YELLOW], + colours[RESET], utest_state.tests[index].name, time, + units[unit_index]); + } else { + printf("%s[ OK ]%s %s (%" UTEST_PRId64 "%s)\n", colours[GREEN], + colours[RESET], utest_state.tests[index].name, time, + units[unit_index]); + } + } + } + + printf("%s[==========]%s %" UTEST_PRIu64 " test cases ran.\n", colours[GREEN], + colours[RESET], ran_tests); + printf("%s[ PASSED ]%s %" UTEST_PRIu64 " tests.\n", colours[GREEN], + colours[RESET], ran_tests - failed - skipped); + + if (0 != skipped) { + printf("%s[ SKIPPED ]%s %" UTEST_PRIu64 " tests, listed below:\n", + colours[YELLOW], colours[RESET], skipped); + for (index = 0; index < skipped_testcases_length; index++) { + printf("%s[ SKIPPED ]%s %s\n", colours[YELLOW], colours[RESET], + utest_state.tests[skipped_testcases[index]].name); + } + } + + if (0 != failed) { + printf("%s[ FAILED ]%s %" UTEST_PRIu64 " tests, listed below:\n", + colours[RED], colours[RESET], failed); + for (index = 0; index < failed_testcases_length; index++) { + printf("%s[ FAILED ]%s %s\n", colours[RED], colours[RESET], + utest_state.tests[failed_testcases[index]].name); + } + } + + if (utest_state.output) { + fprintf(utest_state.output, "\n\n"); + } + +cleanup: + for (index = 0; index < utest_state.tests_length; index++) { + free(UTEST_PTR_CAST(void *, utest_state.tests[index].name)); + } + + free(UTEST_PTR_CAST(void *, skipped_testcases)); + free(UTEST_PTR_CAST(void *, failed_testcases)); + free(UTEST_PTR_CAST(void *, utest_state.tests)); + + if (utest_state.output) { + fclose(utest_state.output); + } + + return UTEST_CAST(int, failed); +} + +#if defined(__clang__) +#if __has_warning("-Wunsafe-buffer-usage") +#pragma clang diagnostic pop +#endif +#endif + +/* + we need, in exactly one source file, define the global struct that will hold + the data we need to run utest. This macro allows the user to declare the + data without having to use the UTEST_MAIN macro, thus allowing them to write + their own main() function. +*/ +#define UTEST_STATE() struct utest_state_s utest_state = {0, 0, 0} + +/* + define a main() function to call into utest.h and start executing tests! A + user can optionally not use this macro, and instead define their own main() + function and manually call utest_main. The user must, in exactly one source + file, use the UTEST_STATE macro to declare a global struct variable that + utest requires. +*/ +#define UTEST_MAIN() \ + UTEST_STATE(); \ + int main(int argc, const char *const argv[]) { \ + return utest_main(argc, argv); \ + } + +#endif /* SHEREDOM_UTEST_H_INCLUDED */ diff --git a/src/thirdparty/libzip/zip.h b/src/thirdparty/libzip/zip.h index f1ff2fad2..6bbe795d9 100644 --- a/src/thirdparty/libzip/zip.h +++ b/src/thirdparty/libzip/zip.h @@ -34,7 +34,7 @@ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - + #ifndef ZIP_EXTERN /*#ifdef _WIN32 @@ -160,7 +160,7 @@ extern "C" { #endif #define ZIP_EM_UNKNOWN 0xffff /* unknown algorithm */ - + enum zip_source_cmd { ZIP_SOURCE_OPEN, /* prepare for reading */ @@ -203,7 +203,7 @@ struct zip_source; typedef zip_int64_t (*zip_source_callback)(void *, void *, zip_uint64_t, enum zip_source_cmd); - + ZIP_EXTERN zip_int64_t zip_add(struct zip *, const char *, struct zip_source *); ZIP_EXTERN zip_int64_t zip_add_dir(struct zip *, const char *); diff --git a/src/thirdparty/libzip/zip_add.c b/src/thirdparty/libzip/zip_add.c index 6a310a836..675df9ec5 100644 --- a/src/thirdparty/libzip/zip_add.c +++ b/src/thirdparty/libzip/zip_add.c @@ -17,7 +17,7 @@ 3. The names of the authors may not be used to endorse or promote products derived from this software without specific prior written permission. - + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE @@ -31,11 +31,11 @@ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - + #include "zipint.h" - + /* NOTE: Return type is signed so we can return -1 on error. @@ -51,6 +51,6 @@ zip_add(struct zip *za, const char *name, struct zip_source *source) _zip_error_set(&za->error, ZIP_ER_INVAL, 0); return -1; } - + return _zip_replace(za, ZIP_UINT64_MAX, name, source); } diff --git a/src/thirdparty/libzip/zip_add_dir.c b/src/thirdparty/libzip/zip_add_dir.c index 28a8ad143..f6d02bcdb 100644 --- a/src/thirdparty/libzip/zip_add_dir.c +++ b/src/thirdparty/libzip/zip_add_dir.c @@ -17,7 +17,7 @@ 3. The names of the authors may not be used to endorse or promote products derived from this software without specific prior written permission. - + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE @@ -31,14 +31,14 @@ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - + #include #include #include "zipint.h" - + /* NOTE: Signed due to -1 on error. See zip_add.c for more details. */ @@ -77,7 +77,7 @@ zip_add_dir(struct zip *za, const char *name) free(s); return -1; } - + ret = _zip_replace(za, -1, s ? s : name, source); free(s); diff --git a/src/thirdparty/libzip/zip_close.c b/src/thirdparty/libzip/zip_close.c index 5e8375596..71231c703 100644 --- a/src/thirdparty/libzip/zip_close.c +++ b/src/thirdparty/libzip/zip_close.c @@ -17,7 +17,7 @@ 3. The names of the authors may not be used to endorse or promote products derived from this software without specific prior written permission. - + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE @@ -31,7 +31,7 @@ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - + #include "zipint.h" @@ -63,14 +63,14 @@ static int _zip_cdir_set_comment(struct zip_cdir *, struct zip *); static char *_zip_create_temp_output(struct zip *, FILE **); static int _zip_torrentzip_cmp(const void *, const void *); - + struct filelist { int idx; const char *name; }; - + ZIP_EXTERN int zip_close(struct zip *za) @@ -108,7 +108,7 @@ zip_close(struct zip *za) } _zip_free(za); return 0; - } + } if ((filelist=(struct filelist *)malloc(sizeof(filelist[0])*survivors)) == NULL) @@ -175,7 +175,7 @@ zip_close(struct zip *za) if (zip_get_archive_flag(za, ZIP_AFL_TORRENT, 0)) _zip_dirent_torrent_normalize(&de); - + /* use it as central directory entry */ memcpy(cd->entry+j, &de, sizeof(cd->entry[j])); @@ -273,7 +273,7 @@ zip_close(struct zip *za) } if (zs) zip_source_free(zs); - + cd->entry[j].last_mod = de.last_mod; cd->entry[j].comp_method = de.comp_method; cd->entry[j].comp_size = de.comp_size; @@ -302,7 +302,7 @@ zip_close(struct zip *za) if (write_cdir(za, cd, out) < 0) error = 1; } - + /* pointers in cd entries are owned by za */ cd->nentry = 0; _zip_cdir_free(cd); @@ -321,7 +321,7 @@ zip_close(struct zip *za) free(temp); return -1; } - + if (za->zp) { fclose(za->zp); za->zp = NULL; @@ -345,11 +345,11 @@ zip_close(struct zip *za) _zip_free(za); free(temp); - + return 0; } - + static int add_data(struct zip *za, struct zip_source *src, struct zip_dirent *de, @@ -360,7 +360,7 @@ add_data(struct zip *za, struct zip_source *src, struct zip_dirent *de, struct zip_source *s2; zip_compression_implementation comp_impl; int ret; - + if (zip_source_stat(src, &st) < 0) { _zip_error_set_from_source(&za->error, src); return -1; @@ -375,7 +375,7 @@ add_data(struct zip *za, struct zip_source *src, struct zip_dirent *de, zip_source_pop(s2); return -1; } - + /* XXX: deflate 0-byte files for torrentzip? */ if (((st.valid & ZIP_STAT_COMP_METHOD) == 0 || st.comp_method == ZIP_CM_STORE) @@ -398,12 +398,12 @@ add_data(struct zip *za, struct zip_source *src, struct zip_dirent *de, s2 = src; offdata = ftello(ft); - + ret = copy_source(za, s2, ft); - + if (zip_source_stat(s2, &st) < 0) ret = -1; - + while (s2 != src) { if ((s2=zip_source_pop(s2)) == NULL) { /* XXX: set erorr */ @@ -433,7 +433,7 @@ add_data(struct zip *za, struct zip_source *src, struct zip_dirent *de, if (_zip_dirent_write(de, ft, 1, &za->error) < 0) return -1; - + if (fseeko(ft, offend, SEEK_SET) < 0) { _zip_error_set(&za->error, ZIP_ER_SEEK, errno); return -1; @@ -442,7 +442,7 @@ add_data(struct zip *za, struct zip_source *src, struct zip_dirent *de, return 0; } - + static int copy_data(FILE *fs, off_t len, FILE *ft, struct zip_error *error) @@ -468,14 +468,14 @@ copy_data(FILE *fs, off_t len, FILE *ft, struct zip_error *error) _zip_error_set(error, ZIP_ER_WRITE, errno); return -1; } - + len -= n; } return 0; } - + static int copy_source(struct zip *za, struct zip_source *src, FILE *ft) @@ -497,19 +497,19 @@ copy_source(struct zip *za, struct zip_source *src, FILE *ft) break; } } - + if (n < 0) { if (ret == 0) _zip_error_set_from_source(&za->error, src); ret = -1; - } + } zip_source_close(src); - + return ret; } - + static int write_cdir(struct zip *za, struct zip_cdir *cd, FILE *out) @@ -517,10 +517,10 @@ write_cdir(struct zip *za, struct zip_cdir *cd, FILE *out) off_t offset; uLong crc; char buf[TORRENT_CRC_LEN+1]; - + if (_zip_cdir_write(cd, out, &za->error) < 0) return -1; - + if (zip_get_archive_flag(za, ZIP_AFL_TORRENT, 0) == 0) return 0; @@ -547,7 +547,7 @@ write_cdir(struct zip *za, struct zip_cdir *cd, FILE *out) return 0; } - + static int _zip_cdir_set_comment(struct zip_cdir *dest, struct zip *src) @@ -571,7 +571,7 @@ _zip_cdir_set_comment(struct zip_cdir *dest, struct zip *src) return 0; } - + int _zip_changed(struct zip *za, int *survivorsp) @@ -599,7 +599,7 @@ _zip_changed(struct zip *za, int *survivorsp) return changed; } - + static char * _zip_create_temp_output(struct zip *za, FILE **outp) @@ -607,7 +607,7 @@ _zip_create_temp_output(struct zip *za, FILE **outp) char *temp; int tfd; FILE *tfp; - + if ((temp=(char *)malloc(strlen(za->zn)+8)) == NULL) { _zip_error_set(&za->error, ZIP_ER_MEMORY, 0); return NULL; @@ -620,7 +620,7 @@ _zip_create_temp_output(struct zip *za, FILE **outp) free(temp); return NULL; } - + if ((tfp=fdopen(tfd, "r+b")) == NULL) { _zip_error_set(&za->error, ZIP_ER_TMPOPEN, errno); close(tfd); @@ -641,7 +641,7 @@ _zip_create_temp_output(struct zip *za, FILE **outp) return temp; } - + static int _zip_torrentzip_cmp(const void *a, const void *b) diff --git a/src/thirdparty/libzip/zip_delete.c b/src/thirdparty/libzip/zip_delete.c index 8178ebbac..65509e8fe 100644 --- a/src/thirdparty/libzip/zip_delete.c +++ b/src/thirdparty/libzip/zip_delete.c @@ -17,7 +17,7 @@ 3. The names of the authors may not be used to endorse or promote products derived from this software without specific prior written permission. - + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE @@ -31,11 +31,11 @@ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - + #include "zipint.h" - + ZIP_EXTERN int zip_delete(struct zip *za, zip_uint64_t idx) @@ -59,5 +59,3 @@ zip_delete(struct zip *za, zip_uint64_t idx) return 0; } - - diff --git a/src/thirdparty/libzip/zip_dirent.c b/src/thirdparty/libzip/zip_dirent.c index b5b9d273b..7f4aff826 100644 --- a/src/thirdparty/libzip/zip_dirent.c +++ b/src/thirdparty/libzip/zip_dirent.c @@ -31,7 +31,7 @@ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - + #include #include @@ -48,7 +48,7 @@ static char *_zip_readstr(unsigned char **, int, int, struct zip_error *); static void _zip_write2(unsigned short, FILE *); static void _zip_write4(unsigned int, FILE *); - + void _zip_cdir_free(struct zip_cdir *cd) @@ -65,7 +65,7 @@ _zip_cdir_free(struct zip_cdir *cd) free(cd); } - + int _zip_cdir_grow(struct zip_cdir *cd, int nentry, struct zip_error *error) @@ -89,7 +89,7 @@ _zip_cdir_grow(struct zip_cdir *cd, int nentry, struct zip_error *error) return 0; } - + struct zip_cdir * _zip_cdir_new(int nentry, struct zip_error *error) @@ -118,7 +118,7 @@ _zip_cdir_new(int nentry, struct zip_error *error) return cd; } - + int _zip_cdir_write(struct zip_cdir *cd, FILE *fp, struct zip_error *error) @@ -152,7 +152,7 @@ _zip_cdir_write(struct zip_cdir *cd, FILE *fp, struct zip_error *error) return 0; } - + void _zip_dirent_finalize(struct zip_dirent *zde) @@ -165,7 +165,7 @@ _zip_dirent_finalize(struct zip_dirent *zde) zde->comment = NULL; } - + void _zip_dirent_init(struct zip_dirent *de) @@ -190,7 +190,7 @@ _zip_dirent_init(struct zip_dirent *de) de->offset = 0; } - + /* _zip_dirent_read(zde, fp, bufp, left, localp, error): Fills the zip directory entry zde. @@ -346,7 +346,7 @@ _zip_dirent_read(struct zip_dirent *zde, FILE *fp, return 0; } - + /* _zip_dirent_torrent_normalize(de); Set values suitable for torrentzip. @@ -403,7 +403,7 @@ _zip_dirent_torrent_normalize(struct zip_dirent *de) de->comment_len = 0; } - + /* _zip_dirent_write(zde, fp, localp, error): Writes zip directory entry zde to file fp. @@ -467,7 +467,7 @@ _zip_dirent_write(struct zip_dirent *zde, FILE *fp, int localp, return 0; } - + static time_t _zip_d2u_time(int dtime, int ddate) @@ -490,7 +490,7 @@ _zip_d2u_time(int dtime, int ddate) return mktime(&tm); } - + unsigned short _zip_read2(unsigned char **a) @@ -503,7 +503,7 @@ _zip_read2(unsigned char **a) return ret; } - + unsigned int _zip_read4(unsigned char **a) @@ -516,7 +516,7 @@ _zip_read4(unsigned char **a) return ret; } - + static char * _zip_readfpstr(FILE *fp, unsigned int len, int nulp, struct zip_error *error) @@ -546,7 +546,7 @@ _zip_readfpstr(FILE *fp, unsigned int len, int nulp, struct zip_error *error) return r; } - + static char * _zip_readstr(unsigned char **buf, int len, int nulp, struct zip_error *error) @@ -573,7 +573,7 @@ _zip_readstr(unsigned char **buf, int len, int nulp, struct zip_error *error) return r; } - + static void _zip_write2(unsigned short i, FILE *fp) @@ -584,7 +584,7 @@ _zip_write2(unsigned short i, FILE *fp) return; } - + static void _zip_write4(unsigned int i, FILE *fp) @@ -597,7 +597,7 @@ _zip_write4(unsigned int i, FILE *fp) return; } - + void _zip_u2d_time(time_t time, unsigned short *dtime, unsigned short *ddate) diff --git a/src/thirdparty/libzip/zip_entry_free.c b/src/thirdparty/libzip/zip_entry_free.c index e8a77707f..f6e9330ca 100644 --- a/src/thirdparty/libzip/zip_entry_free.c +++ b/src/thirdparty/libzip/zip_entry_free.c @@ -31,13 +31,13 @@ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - + #include #include "zipint.h" - + void _zip_entry_free(struct zip_entry *ze) diff --git a/src/thirdparty/libzip/zip_entry_new.c b/src/thirdparty/libzip/zip_entry_new.c index ad5d59975..974721908 100644 --- a/src/thirdparty/libzip/zip_entry_new.c +++ b/src/thirdparty/libzip/zip_entry_new.c @@ -31,13 +31,13 @@ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - + #include #include "zipint.h" - + struct zip_entry * _zip_entry_new(struct zip *za) diff --git a/src/thirdparty/libzip/zip_err_str.c b/src/thirdparty/libzip/zip_err_str.c index 8fb60036e..bc7f850a3 100644 --- a/src/thirdparty/libzip/zip_err_str.c +++ b/src/thirdparty/libzip/zip_err_str.c @@ -5,7 +5,7 @@ #include "zipint.h" - + const char * const _zip_err_str[] = { "No error", diff --git a/src/thirdparty/libzip/zip_error.c b/src/thirdparty/libzip/zip_error.c index b8d907abf..e82b374c6 100644 --- a/src/thirdparty/libzip/zip_error.c +++ b/src/thirdparty/libzip/zip_error.c @@ -31,13 +31,13 @@ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - + #include #include "zipint.h" - + void _zip_error_clear(struct zip_error *err) @@ -46,7 +46,7 @@ _zip_error_clear(struct zip_error *err) err->sys_err = 0; } - + void _zip_error_copy(struct zip_error *dst, struct zip_error *src) @@ -55,7 +55,7 @@ _zip_error_copy(struct zip_error *dst, struct zip_error *src) dst->sys_err = src->sys_err; } - + void _zip_error_fini(struct zip_error *err) @@ -64,7 +64,7 @@ _zip_error_fini(struct zip_error *err) err->str = NULL; } - + void _zip_error_get(struct zip_error *err, int *zep, int *sep) @@ -79,7 +79,7 @@ _zip_error_get(struct zip_error *err, int *zep, int *sep) } } - + void _zip_error_init(struct zip_error *err) @@ -89,7 +89,7 @@ _zip_error_init(struct zip_error *err) err->str = NULL; } - + void _zip_error_set(struct zip_error *err, int ze, int se) @@ -100,7 +100,7 @@ _zip_error_set(struct zip_error *err, int ze, int se) } } - + void _zip_error_set_from_source(struct zip_error *err, struct zip_source *src) diff --git a/src/thirdparty/libzip/zip_error_clear.c b/src/thirdparty/libzip/zip_error_clear.c index 364383ebe..a45a3fad3 100644 --- a/src/thirdparty/libzip/zip_error_clear.c +++ b/src/thirdparty/libzip/zip_error_clear.c @@ -31,11 +31,11 @@ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - + #include "zipint.h" - + ZIP_EXTERN void zip_error_clear(struct zip *za) diff --git a/src/thirdparty/libzip/zip_error_get.c b/src/thirdparty/libzip/zip_error_get.c index 6d1c958c1..38cf5c315 100644 --- a/src/thirdparty/libzip/zip_error_get.c +++ b/src/thirdparty/libzip/zip_error_get.c @@ -31,11 +31,11 @@ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - + #include "zipint.h" - + ZIP_EXTERN void zip_error_get(struct zip *za, int *zep, int *sep) diff --git a/src/thirdparty/libzip/zip_error_get_sys_type.c b/src/thirdparty/libzip/zip_error_get_sys_type.c index 6c6f38074..a58279501 100644 --- a/src/thirdparty/libzip/zip_error_get_sys_type.c +++ b/src/thirdparty/libzip/zip_error_get_sys_type.c @@ -31,11 +31,11 @@ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - + #include "zipint.h" - + ZIP_EXTERN int zip_error_get_sys_type(int ze) diff --git a/src/thirdparty/libzip/zip_error_strerror.c b/src/thirdparty/libzip/zip_error_strerror.c index 3d0951cfb..37dc56347 100644 --- a/src/thirdparty/libzip/zip_error_strerror.c +++ b/src/thirdparty/libzip/zip_error_strerror.c @@ -31,7 +31,7 @@ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - + #include #include @@ -40,7 +40,7 @@ #include "zipint.h" - + const char * _zip_error_strerror(struct zip_error *err) diff --git a/src/thirdparty/libzip/zip_error_to_str.c b/src/thirdparty/libzip/zip_error_to_str.c index 11a0cd2bb..cbc1ef853 100644 --- a/src/thirdparty/libzip/zip_error_to_str.c +++ b/src/thirdparty/libzip/zip_error_to_str.c @@ -31,7 +31,7 @@ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - + #include #include @@ -40,7 +40,7 @@ #include "zipint.h" - + ZIP_EXTERN int zip_error_to_str(char *buf, zip_uint64_t len, int ze, int se) diff --git a/src/thirdparty/libzip/zip_fclose.c b/src/thirdparty/libzip/zip_fclose.c index 8a15febff..fe5247d84 100644 --- a/src/thirdparty/libzip/zip_fclose.c +++ b/src/thirdparty/libzip/zip_fclose.c @@ -31,13 +31,13 @@ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - + #include #include "zipint.h" - + ZIP_EXTERN int zip_fclose(struct zip_file *zf) diff --git a/src/thirdparty/libzip/zip_fdopen.c b/src/thirdparty/libzip/zip_fdopen.c index 60d76a458..ad8893276 100644 --- a/src/thirdparty/libzip/zip_fdopen.c +++ b/src/thirdparty/libzip/zip_fdopen.c @@ -31,13 +31,13 @@ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - + #include "zipint.h" #ifdef ZIP_HAVE_UNISTD_H #include #endif - + ZIP_EXTERN struct zip * zip_fdopen(int fd_orig, int flags, int *zep) diff --git a/src/thirdparty/libzip/zip_file_error_clear.c b/src/thirdparty/libzip/zip_file_error_clear.c index ef6fa10e4..562fee1f7 100644 --- a/src/thirdparty/libzip/zip_file_error_clear.c +++ b/src/thirdparty/libzip/zip_file_error_clear.c @@ -31,11 +31,11 @@ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - + #include "zipint.h" - + ZIP_EXTERN void zip_file_error_clear(struct zip_file *zf) diff --git a/src/thirdparty/libzip/zip_file_error_get.c b/src/thirdparty/libzip/zip_file_error_get.c index f20e011fc..58c69ee87 100644 --- a/src/thirdparty/libzip/zip_file_error_get.c +++ b/src/thirdparty/libzip/zip_file_error_get.c @@ -31,11 +31,11 @@ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - + #include "zipint.h" - + ZIP_EXTERN void zip_file_error_get(struct zip_file *zf, int *zep, int *sep) diff --git a/src/thirdparty/libzip/zip_file_get_offset.c b/src/thirdparty/libzip/zip_file_get_offset.c index b96fd5e48..ee41636aa 100644 --- a/src/thirdparty/libzip/zip_file_get_offset.c +++ b/src/thirdparty/libzip/zip_file_get_offset.c @@ -31,7 +31,7 @@ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - + #include #include @@ -42,7 +42,7 @@ #include "zipint.h" - + /* _zip_file_get_offset(za, ze): Returns the offset of the file data for entry ze. diff --git a/src/thirdparty/libzip/zip_file_strerror.c b/src/thirdparty/libzip/zip_file_strerror.c index 9ba70f14f..509e2f3db 100644 --- a/src/thirdparty/libzip/zip_file_strerror.c +++ b/src/thirdparty/libzip/zip_file_strerror.c @@ -31,11 +31,11 @@ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - + #include "zipint.h" - + ZIP_EXTERN const char * zip_file_strerror(struct zip_file *zf) diff --git a/src/thirdparty/libzip/zip_filerange_crc.c b/src/thirdparty/libzip/zip_filerange_crc.c index 4d1ad5669..2c383e72a 100644 --- a/src/thirdparty/libzip/zip_filerange_crc.c +++ b/src/thirdparty/libzip/zip_filerange_crc.c @@ -31,7 +31,7 @@ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - + #include #include @@ -39,7 +39,7 @@ #include "zipint.h" - + int _zip_filerange_crc(FILE *fp, off_t start, off_t len, uLong *crcp, diff --git a/src/thirdparty/libzip/zip_fopen.c b/src/thirdparty/libzip/zip_fopen.c index 5a65ebaec..483f28149 100644 --- a/src/thirdparty/libzip/zip_fopen.c +++ b/src/thirdparty/libzip/zip_fopen.c @@ -31,11 +31,11 @@ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - + #include "zipint.h" - + ZIP_EXTERN struct zip_file * zip_fopen(struct zip *za, const char *fname, int flags) diff --git a/src/thirdparty/libzip/zip_fopen_encrypted.c b/src/thirdparty/libzip/zip_fopen_encrypted.c index 0a4b131ae..8292684f3 100644 --- a/src/thirdparty/libzip/zip_fopen_encrypted.c +++ b/src/thirdparty/libzip/zip_fopen_encrypted.c @@ -31,11 +31,11 @@ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - + #include "zipint.h" - + ZIP_EXTERN struct zip_file * zip_fopen_encrypted(struct zip *za, const char *fname, int flags, diff --git a/src/thirdparty/libzip/zip_fopen_index.c b/src/thirdparty/libzip/zip_fopen_index.c index 3a58bbed9..d1ad8259b 100644 --- a/src/thirdparty/libzip/zip_fopen_index.c +++ b/src/thirdparty/libzip/zip_fopen_index.c @@ -31,7 +31,7 @@ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - + #include #include @@ -39,7 +39,7 @@ #include "zipint.h" - + ZIP_EXTERN struct zip_file * zip_fopen_index(struct zip *za, zip_uint64_t fileno, int flags) diff --git a/src/thirdparty/libzip/zip_fopen_index_encrypted.c b/src/thirdparty/libzip/zip_fopen_index_encrypted.c index 2e617bf1e..49c0d6ed8 100644 --- a/src/thirdparty/libzip/zip_fopen_index_encrypted.c +++ b/src/thirdparty/libzip/zip_fopen_index_encrypted.c @@ -31,7 +31,7 @@ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - + #include #include @@ -41,7 +41,7 @@ static struct zip_file *_zip_file_new(struct zip *za); - + ZIP_EXTERN struct zip_file * zip_fopen_index_encrypted(struct zip *za, zip_uint64_t fileno, int flags, @@ -154,7 +154,7 @@ zip_fopen_index_encrypted(struct zip *za, zip_uint64_t fileno, int flags, return zf; } - + static struct zip_file * _zip_file_new(struct zip *za) diff --git a/src/thirdparty/libzip/zip_fread.c b/src/thirdparty/libzip/zip_fread.c index 8235c6dfa..901e2f102 100644 --- a/src/thirdparty/libzip/zip_fread.c +++ b/src/thirdparty/libzip/zip_fread.c @@ -31,11 +31,11 @@ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - + #include "zipint.h" - + ZIP_EXTERN zip_int64_t zip_fread(struct zip_file *zf, void *outbuf, zip_uint64_t toread) diff --git a/src/thirdparty/libzip/zip_free.c b/src/thirdparty/libzip/zip_free.c index 9932c14fe..3122a5133 100644 --- a/src/thirdparty/libzip/zip_free.c +++ b/src/thirdparty/libzip/zip_free.c @@ -31,13 +31,13 @@ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - + #include #include "zipint.h" - + /* _zip_free: frees the space allocated to a zipfile struct, and closes the diff --git a/src/thirdparty/libzip/zip_get_archive_comment.c b/src/thirdparty/libzip/zip_get_archive_comment.c index 669eb7021..ef798cfba 100644 --- a/src/thirdparty/libzip/zip_get_archive_comment.c +++ b/src/thirdparty/libzip/zip_get_archive_comment.c @@ -31,11 +31,11 @@ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - + #include "zipint.h" - + ZIP_EXTERN const char * zip_get_archive_comment(struct zip *za, int *lenp, int flags) diff --git a/src/thirdparty/libzip/zip_get_archive_flag.c b/src/thirdparty/libzip/zip_get_archive_flag.c index 4733d92b5..64e415898 100644 --- a/src/thirdparty/libzip/zip_get_archive_flag.c +++ b/src/thirdparty/libzip/zip_get_archive_flag.c @@ -31,11 +31,11 @@ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - + #include "zipint.h" - + ZIP_EXTERN int zip_get_archive_flag(struct zip *za, int flag, int flags) diff --git a/src/thirdparty/libzip/zip_get_compression_implementation.c b/src/thirdparty/libzip/zip_get_compression_implementation.c index 8d4ccb69a..c48045b45 100644 --- a/src/thirdparty/libzip/zip_get_compression_implementation.c +++ b/src/thirdparty/libzip/zip_get_compression_implementation.c @@ -31,11 +31,11 @@ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - + #include "zipint.h" - + ZIP_EXTERN zip_compression_implementation zip_get_compression_implementation(zip_uint16_t cm) diff --git a/src/thirdparty/libzip/zip_get_encryption_implementation.c b/src/thirdparty/libzip/zip_get_encryption_implementation.c index d83698c86..49fbaca2f 100644 --- a/src/thirdparty/libzip/zip_get_encryption_implementation.c +++ b/src/thirdparty/libzip/zip_get_encryption_implementation.c @@ -31,11 +31,11 @@ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - + #include "zipint.h" - + ZIP_EXTERN zip_encryption_implementation zip_get_encryption_implementation(zip_uint16_t em) diff --git a/src/thirdparty/libzip/zip_get_file_comment.c b/src/thirdparty/libzip/zip_get_file_comment.c index b9dacbe5f..886bedc08 100644 --- a/src/thirdparty/libzip/zip_get_file_comment.c +++ b/src/thirdparty/libzip/zip_get_file_comment.c @@ -31,11 +31,11 @@ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - + #include "zipint.h" - + ZIP_EXTERN const char * zip_get_file_comment(struct zip *za, zip_uint64_t idx, int *lenp, int flags) diff --git a/src/thirdparty/libzip/zip_get_name.c b/src/thirdparty/libzip/zip_get_name.c index 531af5029..b74299379 100644 --- a/src/thirdparty/libzip/zip_get_name.c +++ b/src/thirdparty/libzip/zip_get_name.c @@ -31,11 +31,11 @@ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - + #include "zipint.h" - + ZIP_EXTERN const char * zip_get_name(struct zip *za, zip_uint64_t idx, int flags) @@ -43,7 +43,7 @@ zip_get_name(struct zip *za, zip_uint64_t idx, int flags) return _zip_get_name(za, idx, flags, &za->error); } - + const char * _zip_get_name(struct zip *za, zip_uint64_t idx, int flags, diff --git a/src/thirdparty/libzip/zip_get_num_entries.c b/src/thirdparty/libzip/zip_get_num_entries.c index 83293e955..7da9a74b7 100644 --- a/src/thirdparty/libzip/zip_get_num_entries.c +++ b/src/thirdparty/libzip/zip_get_num_entries.c @@ -31,11 +31,11 @@ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - + #include "zipint.h" - + ZIP_EXTERN zip_uint64_t zip_get_num_entries(struct zip *za, int flags) diff --git a/src/thirdparty/libzip/zip_get_num_files.c b/src/thirdparty/libzip/zip_get_num_files.c index 1d9baa3d6..740c509fe 100644 --- a/src/thirdparty/libzip/zip_get_num_files.c +++ b/src/thirdparty/libzip/zip_get_num_files.c @@ -31,11 +31,11 @@ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - + #include "zipint.h" - + ZIP_EXTERN int zip_get_num_files(struct zip *za) diff --git a/src/thirdparty/libzip/zip_memdup.c b/src/thirdparty/libzip/zip_memdup.c index 641125ed2..fa9bc6f3a 100644 --- a/src/thirdparty/libzip/zip_memdup.c +++ b/src/thirdparty/libzip/zip_memdup.c @@ -36,7 +36,7 @@ #include "zipint.h" - + void * _zip_memdup(const void *mem, size_t len, struct zip_error *error) diff --git a/src/thirdparty/libzip/zip_name_locate.c b/src/thirdparty/libzip/zip_name_locate.c index 89cc15922..0849353d4 100644 --- a/src/thirdparty/libzip/zip_name_locate.c +++ b/src/thirdparty/libzip/zip_name_locate.c @@ -31,13 +31,13 @@ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - + #include #include "zipint.h" - + ZIP_EXTERN int zip_name_locate(struct zip *za, const char *fname, int flags) @@ -45,7 +45,7 @@ zip_name_locate(struct zip *za, const char *fname, int flags) return _zip_name_locate(za, fname, flags, &za->error); } - + int _zip_name_locate(struct zip *za, const char *fname, int flags, diff --git a/src/thirdparty/libzip/zip_new.c b/src/thirdparty/libzip/zip_new.c index 7ce1237cd..81bb4a746 100644 --- a/src/thirdparty/libzip/zip_new.c +++ b/src/thirdparty/libzip/zip_new.c @@ -31,13 +31,13 @@ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - + #include #include "zipint.h" - + /* _zip_new: creates a new zipfile struct, and sets the contents to zero; returns diff --git a/src/thirdparty/libzip/zip_open.c b/src/thirdparty/libzip/zip_open.c index 015c91e44..05821c1d0 100644 --- a/src/thirdparty/libzip/zip_open.c +++ b/src/thirdparty/libzip/zip_open.c @@ -31,7 +31,7 @@ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - + #include #include @@ -55,7 +55,7 @@ static unsigned char *_zip_memmem(const unsigned char *, int, static struct zip_cdir *_zip_readcdir(FILE *, off_t, unsigned char *, unsigned char *, int, int, struct zip_error *); - + ZIP_EXTERN struct zip * zip_open(const char *fn, int flags, int *zep) @@ -79,7 +79,7 @@ zip_open(const char *fn, int flags, int *zep) return _zip_open(fn, fp, flags, 0, zep); } - + struct zip * _zip_open(const char *fn, FILE *fp, int flags, int aflags, int *zep) @@ -134,7 +134,7 @@ _zip_open(const char *fn, FILE *fp, int flags, int aflags, int *zep) return za; } - + static void set_error(int *zep, struct zip_error *err, int ze) @@ -151,7 +151,7 @@ set_error(int *zep, struct zip_error *err, int ze) *zep = ze; } - + /* _zip_readcdir: tries to find a valid end-of-central-directory at the beginning of @@ -281,7 +281,7 @@ _zip_readcdir(FILE *fp, off_t buf_offset, unsigned char *buf, unsigned char *eoc return cd; } - + /* _zip_checkcons: Checks the consistency of the central directory by comparing central @@ -339,7 +339,7 @@ _zip_checkcons(FILE *fp, struct zip_cdir *cd, struct zip_error *error) return max - min; } - + /* _zip_check_torrentzip: check wether ZA has a valid TORRENTZIP comment, i.e. is torrentzipped */ @@ -374,7 +374,7 @@ _zip_check_torrentzip(struct zip *za) } - + /* _zip_headercomp: compares two headers h1 and h2; if they are local headers, set @@ -443,7 +443,7 @@ _zip_headercomp(struct zip_dirent *h1, int local1p, struct zip_dirent *h2, return 0; } - + static struct zip * _zip_allocate_new(const char *fn, int *zep) @@ -469,7 +469,7 @@ _zip_allocate_new(const char *fn, int *zep) return za; } - + static int _zip_file_exists(const char *fn, int flags, int *zep) @@ -499,7 +499,7 @@ _zip_file_exists(const char *fn, int flags, int *zep) return 1; } - + static struct zip_cdir * _zip_find_central_dir(FILE *fp, int flags, int *zep, off_t len) @@ -580,7 +580,7 @@ _zip_find_central_dir(FILE *fp, int flags, int *zep, off_t len) return cdir; } - + static unsigned char * _zip_memmem(const unsigned char *big, int biglen, const unsigned char *little, diff --git a/src/thirdparty/libzip/zip_rename.c b/src/thirdparty/libzip/zip_rename.c index d78bbe8bc..e1911c363 100644 --- a/src/thirdparty/libzip/zip_rename.c +++ b/src/thirdparty/libzip/zip_rename.c @@ -31,13 +31,13 @@ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - + #include #include "zipint.h" - + ZIP_EXTERN int zip_rename(struct zip *za, zip_uint64_t idx, const char *name) diff --git a/src/thirdparty/libzip/zip_replace.c b/src/thirdparty/libzip/zip_replace.c index c444e78dc..5e2789aed 100644 --- a/src/thirdparty/libzip/zip_replace.c +++ b/src/thirdparty/libzip/zip_replace.c @@ -31,11 +31,11 @@ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - + #include "zipint.h" - + ZIP_EXTERN int zip_replace(struct zip *za, zip_uint64_t idx, struct zip_source *source) @@ -52,7 +52,7 @@ zip_replace(struct zip *za, zip_uint64_t idx, struct zip_source *source) } - + /* NOTE: Signed due to -1 on error. See zip_add.c for more details. */ diff --git a/src/thirdparty/libzip/zip_set_archive_comment.c b/src/thirdparty/libzip/zip_set_archive_comment.c index 3bb85d10e..c74c197a9 100644 --- a/src/thirdparty/libzip/zip_set_archive_comment.c +++ b/src/thirdparty/libzip/zip_set_archive_comment.c @@ -31,13 +31,13 @@ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - + #include #include "zipint.h" - + ZIP_EXTERN int zip_set_archive_comment(struct zip *za, const char *comment, int len) diff --git a/src/thirdparty/libzip/zip_set_archive_flag.c b/src/thirdparty/libzip/zip_set_archive_flag.c index e0e713a41..f7092ed5a 100644 --- a/src/thirdparty/libzip/zip_set_archive_flag.c +++ b/src/thirdparty/libzip/zip_set_archive_flag.c @@ -31,11 +31,11 @@ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - + #include "zipint.h" - + ZIP_EXTERN int zip_set_archive_flag(struct zip *za, int flag, int value) diff --git a/src/thirdparty/libzip/zip_set_default_password.c b/src/thirdparty/libzip/zip_set_default_password.c index b9aa80acf..0e4ee285e 100644 --- a/src/thirdparty/libzip/zip_set_default_password.c +++ b/src/thirdparty/libzip/zip_set_default_password.c @@ -31,14 +31,14 @@ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - + #include #include #include "zipint.h" - + ZIP_EXTERN int zip_set_default_password(struct zip *za, const char *passwd) diff --git a/src/thirdparty/libzip/zip_set_file_comment.c b/src/thirdparty/libzip/zip_set_file_comment.c index 6ae76a0c3..ecfb1a718 100644 --- a/src/thirdparty/libzip/zip_set_file_comment.c +++ b/src/thirdparty/libzip/zip_set_file_comment.c @@ -31,13 +31,13 @@ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - + #include #include "zipint.h" - + ZIP_EXTERN int zip_set_file_comment(struct zip *za, zip_uint64_t idx, diff --git a/src/thirdparty/libzip/zip_set_name.c b/src/thirdparty/libzip/zip_set_name.c index 2a90601bf..1d92db5f4 100644 --- a/src/thirdparty/libzip/zip_set_name.c +++ b/src/thirdparty/libzip/zip_set_name.c @@ -31,14 +31,14 @@ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - + #include #include #include "zipint.h" - + int _zip_set_name(struct zip *za, zip_uint64_t idx, const char *name) diff --git a/src/thirdparty/libzip/zip_source_buffer.c b/src/thirdparty/libzip/zip_source_buffer.c index af8bf1939..95e3fea9b 100644 --- a/src/thirdparty/libzip/zip_source_buffer.c +++ b/src/thirdparty/libzip/zip_source_buffer.c @@ -31,7 +31,7 @@ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - + #include #include @@ -46,7 +46,7 @@ struct read_data { static zip_int64_t read_data(void *, void *, zip_uint64_t, enum zip_source_cmd); - + ZIP_EXTERN struct zip_source * zip_source_buffer(struct zip *za, const void *data, zip_uint64_t len, int freep) @@ -80,7 +80,7 @@ zip_source_buffer(struct zip *za, const void *data, zip_uint64_t len, int freep) return zs; } - + static zip_int64_t read_data(void *state, void *data, zip_uint64_t len, enum zip_source_cmd cmd) diff --git a/src/thirdparty/libzip/zip_source_close.c b/src/thirdparty/libzip/zip_source_close.c index 882a1997b..d2eeca214 100644 --- a/src/thirdparty/libzip/zip_source_close.c +++ b/src/thirdparty/libzip/zip_source_close.c @@ -31,11 +31,11 @@ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - + #include "zipint.h" - + ZIP_EXTERN void zip_source_close(struct zip_source *src) diff --git a/src/thirdparty/libzip/zip_source_crc.c b/src/thirdparty/libzip/zip_source_crc.c index 59e8a1959..b2ae9dfeb 100644 --- a/src/thirdparty/libzip/zip_source_crc.c +++ b/src/thirdparty/libzip/zip_source_crc.c @@ -31,7 +31,7 @@ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - + #include #include @@ -49,7 +49,7 @@ struct crc { static zip_int64_t crc_read(struct zip_source *, void *, void * , zip_uint64_t, enum zip_source_cmd); - + ZIP_EXTERN struct zip_source * zip_source_crc(struct zip *za, struct zip_source *src, int validate) @@ -71,7 +71,7 @@ zip_source_crc(struct zip *za, struct zip_source *src, int validate) return zip_source_layered(za, src, crc_read, ctx); } - + static zip_int64_t crc_read(struct zip_source *src, void *_ctx, void *data, diff --git a/src/thirdparty/libzip/zip_source_deflate.c b/src/thirdparty/libzip/zip_source_deflate.c index 0cbcd7ca7..50ec61cf0 100644 --- a/src/thirdparty/libzip/zip_source_deflate.c +++ b/src/thirdparty/libzip/zip_source_deflate.c @@ -31,7 +31,7 @@ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - + #include #include @@ -58,7 +58,7 @@ static zip_int64_t deflate_decompress(struct zip_source *, void *, void *, zip_uint64_t, enum zip_source_cmd); static void deflate_free(struct deflate *); - + ZIP_EXTERN struct zip_source * zip_source_deflate(struct zip *za, struct zip_source *src, @@ -97,7 +97,7 @@ zip_source_deflate(struct zip *za, struct zip_source *src, return s2; } - + static zip_int64_t compress_read(struct zip_source *src, struct deflate *ctx, @@ -172,7 +172,7 @@ compress_read(struct zip_source *src, struct deflate *ctx, return (ctx->e[0] == 0) ? 0 : -1; } - + static zip_int64_t decompress_read(struct zip_source *src, struct deflate *ctx, @@ -242,7 +242,7 @@ decompress_read(struct zip_source *src, struct deflate *ctx, return (ctx->e[0] == 0) ? 0 : -1; } - + static zip_int64_t deflate_compress(struct zip_source *src, void *ud, void *data, @@ -313,7 +313,7 @@ deflate_compress(struct zip_source *src, void *ud, void *data, } } - + static zip_int64_t deflate_decompress(struct zip_source *src, void *ud, void *data, @@ -384,7 +384,7 @@ deflate_decompress(struct zip_source *src, void *ud, void *data, } - + static void deflate_free(struct deflate *ctx) diff --git a/src/thirdparty/libzip/zip_source_error.c b/src/thirdparty/libzip/zip_source_error.c index 433b450b6..8eb712147 100644 --- a/src/thirdparty/libzip/zip_source_error.c +++ b/src/thirdparty/libzip/zip_source_error.c @@ -31,11 +31,11 @@ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - + #include "zipint.h" - + ZIP_EXTERN void zip_source_error(struct zip_source *src, int *ze, int *se) diff --git a/src/thirdparty/libzip/zip_source_file.c b/src/thirdparty/libzip/zip_source_file.c index 79c8ee5ac..8ebe518d8 100644 --- a/src/thirdparty/libzip/zip_source_file.c +++ b/src/thirdparty/libzip/zip_source_file.c @@ -31,14 +31,14 @@ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - + #include #include #include "zipint.h" - + ZIP_EXTERN struct zip_source * zip_source_file(struct zip *za, const char *fname, zip_uint64_t start, diff --git a/src/thirdparty/libzip/zip_source_filep.c b/src/thirdparty/libzip/zip_source_filep.c index 7e26ff6c5..7401e462b 100644 --- a/src/thirdparty/libzip/zip_source_filep.c +++ b/src/thirdparty/libzip/zip_source_filep.c @@ -31,7 +31,7 @@ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - + #include #include @@ -56,7 +56,7 @@ struct read_file { static zip_int64_t read_file(void *state, void *data, zip_uint64_t len, enum zip_source_cmd cmd); - + ZIP_EXTERN struct zip_source * zip_source_filep(struct zip *za, FILE *file, zip_uint64_t start, @@ -73,7 +73,7 @@ zip_source_filep(struct zip *za, FILE *file, zip_uint64_t start, return _zip_source_file_or_p(za, NULL, file, start, len, 1, NULL); } - + struct zip_source * _zip_source_file_or_p(struct zip *za, const char *fname, FILE *file, @@ -118,7 +118,7 @@ _zip_source_file_or_p(struct zip *za, const char *fname, FILE *file, return zs; } - + static zip_int64_t read_file(void *state, void *data, zip_uint64_t len, enum zip_source_cmd cmd) diff --git a/src/thirdparty/libzip/zip_source_free.c b/src/thirdparty/libzip/zip_source_free.c index b1e784049..1027234d0 100644 --- a/src/thirdparty/libzip/zip_source_free.c +++ b/src/thirdparty/libzip/zip_source_free.c @@ -31,13 +31,13 @@ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - + #include #include "zipint.h" - + ZIP_EXTERN void zip_source_free(struct zip_source *src) diff --git a/src/thirdparty/libzip/zip_source_function.c b/src/thirdparty/libzip/zip_source_function.c index cb92e339b..64b91d307 100644 --- a/src/thirdparty/libzip/zip_source_function.c +++ b/src/thirdparty/libzip/zip_source_function.c @@ -31,13 +31,13 @@ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - + #include #include "zipint.h" - + ZIP_EXTERN struct zip_source * zip_source_function(struct zip *za, zip_source_callback zcb, void *ud) @@ -56,7 +56,7 @@ zip_source_function(struct zip *za, zip_source_callback zcb, void *ud) return zs; } - + struct zip_source * _zip_source_new(struct zip *za) diff --git a/src/thirdparty/libzip/zip_source_layered.c b/src/thirdparty/libzip/zip_source_layered.c index 9bdf3c5ae..f1ef20d77 100644 --- a/src/thirdparty/libzip/zip_source_layered.c +++ b/src/thirdparty/libzip/zip_source_layered.c @@ -31,13 +31,13 @@ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - + #include #include "zipint.h" - + ZIP_EXTERN struct zip_source * zip_source_layered(struct zip *za, struct zip_source *src, diff --git a/src/thirdparty/libzip/zip_source_open.c b/src/thirdparty/libzip/zip_source_open.c index a279e20b7..d22fe7e1b 100644 --- a/src/thirdparty/libzip/zip_source_open.c +++ b/src/thirdparty/libzip/zip_source_open.c @@ -31,11 +31,11 @@ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - + #include "zipint.h" - + ZIP_EXTERN int zip_source_open(struct zip_source *src) diff --git a/src/thirdparty/libzip/zip_source_pkware.c b/src/thirdparty/libzip/zip_source_pkware.c index 21f4be4f9..11accd1b8 100644 --- a/src/thirdparty/libzip/zip_source_pkware.c +++ b/src/thirdparty/libzip/zip_source_pkware.c @@ -31,7 +31,7 @@ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - + #include #include @@ -53,7 +53,7 @@ static const uLongf *crc = NULL; #define CRC32(c, b) (crc[((c) ^ (b)) & 0xff] ^ ((c) >> 8)) - + static void decrypt(struct trad_pkware *, zip_uint8_t *, const zip_uint8_t *, zip_uint64_t, int); @@ -62,7 +62,7 @@ static zip_int64_t pkware_decrypt(struct zip_source *, void *, void *, zip_uint64_t, enum zip_source_cmd); static void pkware_free(struct trad_pkware *); - + ZIP_EXTERN struct zip_source * zip_source_pkware(struct zip *za, struct zip_source *src, @@ -103,7 +103,7 @@ zip_source_pkware(struct zip *za, struct zip_source *src, return s2; } - + static void decrypt(struct trad_pkware *ctx, zip_uint8_t *out, const zip_uint8_t *in, @@ -135,7 +135,7 @@ decrypt(struct trad_pkware *ctx, zip_uint8_t *out, const zip_uint8_t *in, } } - + static int decrypt_header(struct zip_source *src, struct trad_pkware *ctx) @@ -175,7 +175,7 @@ decrypt_header(struct zip_source *src, struct trad_pkware *ctx) return 0; } - + static zip_int64_t pkware_decrypt(struct zip_source *src, void *ud, void *data, @@ -232,7 +232,7 @@ pkware_decrypt(struct zip_source *src, void *ud, void *data, } } - + static void pkware_free(struct trad_pkware *ctx) diff --git a/src/thirdparty/libzip/zip_source_pop.c b/src/thirdparty/libzip/zip_source_pop.c index 88d37da51..41a289a97 100644 --- a/src/thirdparty/libzip/zip_source_pop.c +++ b/src/thirdparty/libzip/zip_source_pop.c @@ -31,13 +31,13 @@ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - + #include #include "zipint.h" - + ZIP_EXTERN struct zip_source * zip_source_pop(struct zip_source *src) diff --git a/src/thirdparty/libzip/zip_source_read.c b/src/thirdparty/libzip/zip_source_read.c index 432243b44..1db12954f 100644 --- a/src/thirdparty/libzip/zip_source_read.c +++ b/src/thirdparty/libzip/zip_source_read.c @@ -31,11 +31,11 @@ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - + #include "zipint.h" - + ZIP_EXTERN zip_int64_t zip_source_read(struct zip_source *src, void *data, zip_uint64_t len) diff --git a/src/thirdparty/libzip/zip_source_stat.c b/src/thirdparty/libzip/zip_source_stat.c index 2166074d2..2f7ddac0b 100644 --- a/src/thirdparty/libzip/zip_source_stat.c +++ b/src/thirdparty/libzip/zip_source_stat.c @@ -31,11 +31,11 @@ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - + #include "zipint.h" - + ZIP_EXTERN int zip_source_stat(struct zip_source *src, struct zip_stat *st) diff --git a/src/thirdparty/libzip/zip_source_zip.c b/src/thirdparty/libzip/zip_source_zip.c index 2b9061f0c..1ca8159ff 100644 --- a/src/thirdparty/libzip/zip_source_zip.c +++ b/src/thirdparty/libzip/zip_source_zip.c @@ -31,7 +31,7 @@ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - + #include #include @@ -48,7 +48,7 @@ struct read_zip { static zip_int64_t read_zip(void *st, void *data, zip_uint64_t len, enum zip_source_cmd cmd); - + ZIP_EXTERN struct zip_source * zip_source_zip(struct zip *za, struct zip *srcza, zip_uint64_t srcidx, @@ -114,7 +114,7 @@ zip_source_zip(struct zip *za, struct zip *srcza, zip_uint64_t srcidx, return zs; } - + static zip_int64_t read_zip(void *state, void *data, zip_uint64_t len, enum zip_source_cmd cmd) diff --git a/src/thirdparty/libzip/zip_stat.c b/src/thirdparty/libzip/zip_stat.c index df1c0b50b..1df94b5aa 100644 --- a/src/thirdparty/libzip/zip_stat.c +++ b/src/thirdparty/libzip/zip_stat.c @@ -31,11 +31,11 @@ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - + #include "zipint.h" - + ZIP_EXTERN int zip_stat(struct zip *za, const char *fname, int flags, struct zip_stat *st) diff --git a/src/thirdparty/libzip/zip_stat_index.c b/src/thirdparty/libzip/zip_stat_index.c index 0e15b5577..56fd9864b 100644 --- a/src/thirdparty/libzip/zip_stat_index.c +++ b/src/thirdparty/libzip/zip_stat_index.c @@ -31,11 +31,11 @@ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - + #include "zipint.h" - + ZIP_EXTERN int zip_stat_index(struct zip *za, zip_uint64_t index, int flags, diff --git a/src/thirdparty/libzip/zip_stat_init.c b/src/thirdparty/libzip/zip_stat_init.c index d17613bf5..01fa385aa 100644 --- a/src/thirdparty/libzip/zip_stat_init.c +++ b/src/thirdparty/libzip/zip_stat_init.c @@ -31,11 +31,11 @@ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - + #include "zipint.h" - + ZIP_EXTERN void zip_stat_init(struct zip_stat *st) diff --git a/src/thirdparty/libzip/zip_strerror.c b/src/thirdparty/libzip/zip_strerror.c index 9ebee144f..8ca5c9f7e 100644 --- a/src/thirdparty/libzip/zip_strerror.c +++ b/src/thirdparty/libzip/zip_strerror.c @@ -31,11 +31,11 @@ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - + #include "zipint.h" - + ZIP_EXTERN const char * zip_strerror(struct zip *za) diff --git a/src/thirdparty/libzip/zip_unchange.c b/src/thirdparty/libzip/zip_unchange.c index e64186ed6..907dddc14 100644 --- a/src/thirdparty/libzip/zip_unchange.c +++ b/src/thirdparty/libzip/zip_unchange.c @@ -31,13 +31,13 @@ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - + #include #include "zipint.h" - + ZIP_EXTERN int zip_unchange(struct zip *za, zip_uint64_t idx) @@ -45,7 +45,7 @@ zip_unchange(struct zip *za, zip_uint64_t idx) return _zip_unchange(za, idx, 0); } - + int _zip_unchange(struct zip *za, zip_uint64_t idx, int allow_duplicates) diff --git a/src/thirdparty/libzip/zip_unchange_all.c b/src/thirdparty/libzip/zip_unchange_all.c index 54a7a0d2e..f5a5ef323 100644 --- a/src/thirdparty/libzip/zip_unchange_all.c +++ b/src/thirdparty/libzip/zip_unchange_all.c @@ -31,13 +31,13 @@ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - + #include #include "zipint.h" - + ZIP_EXTERN int zip_unchange_all(struct zip *za) diff --git a/src/thirdparty/libzip/zip_unchange_archive.c b/src/thirdparty/libzip/zip_unchange_archive.c index 8f9c024c3..faa804958 100644 --- a/src/thirdparty/libzip/zip_unchange_archive.c +++ b/src/thirdparty/libzip/zip_unchange_archive.c @@ -31,13 +31,13 @@ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - + #include #include "zipint.h" - + ZIP_EXTERN int zip_unchange_archive(struct zip *za) diff --git a/src/thirdparty/libzip/zip_unchange_data.c b/src/thirdparty/libzip/zip_unchange_data.c index 431f2d0c0..183a7fc10 100644 --- a/src/thirdparty/libzip/zip_unchange_data.c +++ b/src/thirdparty/libzip/zip_unchange_data.c @@ -31,7 +31,7 @@ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - + #include diff --git a/src/thirdparty/libzip/zipint.h b/src/thirdparty/libzip/zipint.h index 43cbfa8ff..b9217b462 100644 --- a/src/thirdparty/libzip/zipint.h +++ b/src/thirdparty/libzip/zipint.h @@ -94,7 +94,7 @@ int _zip_mkstemp(char *); #endif #endif - + #define CENTRAL_MAGIC "PK\1\2" #define LOCAL_MAGIC "PK\3\4" @@ -112,7 +112,7 @@ int _zip_mkstemp(char *); #define CDBUFSIZE (MAXCOMLEN+EOCDLEN) #define BUFSIZE 8192 - + /* This section contains API that won't materialize like this. It's placed in the internal section, pending cleanup. */ @@ -131,7 +131,7 @@ ZIP_EXTERN zip_encryption_implementation zip_get_encryption_implementation( zip_uint16_t); - + /* This section contains API that is of limited use until support for user-supplied compression/encryption implementation is finished. @@ -168,7 +168,7 @@ ZIP_EXTERN int zip_source_stat(struct zip_source *, struct zip_stat *); ZIP_EXTERN struct zip_source *zip_source_pop(struct zip_source *); - + /* state of change of a file in zip archive */ @@ -261,7 +261,7 @@ struct zip_cdir { unsigned short comment_len; /* length of zip archive comment */ }; - + struct zip_source { struct zip_source *src; @@ -286,13 +286,13 @@ struct zip_entry { int ch_comment_len; }; - + extern const char * const _zip_err_str[]; extern const int _zip_nerr_str; extern const int _zip_err_type[]; - + #define ZIP_ENTRY_DATA_CHANGED(x) \ ((x)->state == ZIP_ST_REPLACED \ @@ -300,7 +300,7 @@ extern const int _zip_err_type[]; #define ZIP_IS_RDONLY(za) ((za)->ch_flags & ZIP_AFL_RDONLY) - + int _zip_cdir_compute_crc(struct zip *, uLong *); void _zip_cdir_free(struct zip_cdir *);