Skip to content

Commit

Permalink
test: add parser exception test
Browse files Browse the repository at this point in the history
  • Loading branch information
sun128764 committed Sep 21, 2023
1 parent bee0fd3 commit c22d99d
Show file tree
Hide file tree
Showing 6 changed files with 116 additions and 1 deletion.
3 changes: 3 additions & 0 deletions AssParser.Test/AssParser.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@
<None Update="AssParserTest\2.ass">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="AssParserTest\format_14.ass">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="UUEncodeTest\1.ass">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
Expand Down
18 changes: 17 additions & 1 deletion AssParser.Test/AssParserTest/AssParserTest.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using AssParser.Lib;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
Expand Down Expand Up @@ -38,5 +39,20 @@ public void ToString_ShouldBe_Same(string file)
//Assert
Assert.Equal(source.Replace("\r\n", "\n").Replace("\n", "\r\n"), res.Replace("\r\n", "\n").Replace("\n", "\r\n"));
}
[Fact]
public async void AssParser_ShouldThrow_InvalidStyle()
{
//Arrange
var path = Path.Combine("AssParserTest", "format_14.ass");
using var sr = new StreamReader(File.OpenRead(path));

//Act
var act = () => Lib.AssParser.ParseAssFile(sr);

//Assert
var exception = await Assert.ThrowsAsync<AssParserException>(act);
Assert.Equal(14, exception?.LineCount);
Assert.Equal(AssParserErrorType.InvalidStyleLine, exception?.ErrorType);
}
}
}
24 changes: 24 additions & 0 deletions AssParser.Test/AssParserTest/event_23.ass
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
[Script Info]
; Script generated by Aegisub 0-mod-d5c132a
; http://www.aegisub.org/
Comment: [Processed by 繁化姬 dict-7ac3466c-r881 @ 2019/08/22 15:37:24 | https://zhconvert.org
Title: [Nekomoe kissaten] Uma Musume [14][BDRip].JPSC
ScriptType: v4.00+
WrapStyle: 2
ScaledBorderAndShadow: yes
PlayResX: 1280
PlayResY: 720
YCbCr Matrix: TV.709

[V4+ Styles]
Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding
Style: Dial-CH,Tensentype JiaLiDaYuanGB18030,38,&H00FFFFFF,&H000000FF,&H00000000,&H00000000,0,0,0,0,100,100,0,0,1,1,0,2,10,10,30,1
Style: Dial-CH2,Tensentype JiaLiDaYuanGB18030,36,&H00FFFFFF,&H000000FF,&H00000000,&H00000000,0,0,0,0,100,100,0,0,1,1,0,8,10,10,36,1

[Events]
Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text
Comment: 0,0:00:00.00,0:00:00.00,Staff,,0,0,0,,Staff
Dialogue: 0,0:00:05.00,0:00:13.41,Staff,,0,0,0,,{=0}{\fscy100\t(5,8388,\fscy148.63)\fscx100\t(5,8388,\fscx148.63)\move(640,10,672.24,-73.86,5,8388)\alpha&HFF&\t(0,500,\alpha&H00&)\t(7910,8410,\alpha&HFF&)\blur5}本字幕由喵萌奶茶屋制作 仅供交流试看之用 请勿用于商业用途 \N翻译: Ronny 校对: 雨后飘雪 繁化: SashiharaRino 后期: MIR
Comment: 0,0:00:00.00,0:00:00.00,Staff,,0,0,0,,Title
Dialogu: 0,0:02:03.98,0:02:07.98,Title,,0,0,0,,{\clip(452,502,834,504)\pos(640,570)\c&H99A8F2&}BNW的誓言①
Dialogue: 0,0:02:03.98,0:02:07.98,Title,,0,0,0,,{\clip(452,504,834,506)\pos(640,570)\c&H99A8F2&}BNW的誓言①
24 changes: 24 additions & 0 deletions AssParser.Test/AssParserTest/format_14.ass
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
[Script Info]
; Script generated by Aegisub 0-mod-d5c132a
; http://www.aegisub.org/
Comment: [Processed by 繁化姬 dict-7ac3466c-r881 @ 2019/08/22 15:37:24 | https://zhconvert.org
Title: [Nekomoe kissaten] Uma Musume [14][BDRip].JPSC
ScriptType: v4.00+
WrapStyle: 2
ScaledBorderAndShadow: yes
PlayResX: 1280
PlayResY: 720
YCbCr Matrix: TV.709

[V4+ Styles]
Format: Names, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding
Style: Dial-CH,Tensentype JiaLiDaYuanGB18030,38,&H00FFFFFF,&H000000FF,&H00000000,&H00000000,0,0,0,0,100,100,0,0,1,1,0,2,10,10,30,1
Style: Dial-CH2,Tensentype JiaLiDaYuanGB18030,36,&H00FFFFFF,&H000000FF,&H00000000,&H00000000,0,0,0,0,100,100,0,0,1,1,0,8,10,10,36,1

[Events]
Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text
Comment: 0,0:00:00.00,0:00:00.00,Staff,,0,0,0,,Staff
Dialogue: 0,0:00:05.00,0:00:13.41,Staff,,0,0,0,,{=0}{\fscy100\t(5,8388,\fscy148.63)\fscx100\t(5,8388,\fscx148.63)\move(640,10,672.24,-73.86,5,8388)\alpha&HFF&\t(0,500,\alpha&H00&)\t(7910,8410,\alpha&HFF&)\blur5}本字幕由喵萌奶茶屋制作 仅供交流试看之用 请勿用于商业用途 \N翻译: Ronny 校对: 雨后飘雪 繁化: SashiharaRino 后期: MIR
Comment: 0,0:00:00.00,0:00:00.00,Staff,,0,0,0,,Title
Dialogue: 0,0:02:03.98,0:02:07.98,Title,,0,0,0,,{\clip(452,502,834,504)\pos(640,570)\c&H99A8F2&}BNW的誓言①
Dialogue: 0,0:02:03.98,0:02:07.98,Title,,0,0,0,,{\clip(452,504,834,506)\pos(640,570)\c&H99A8F2&}BNW的誓言①
24 changes: 24 additions & 0 deletions AssParser.Test/AssParserTest/format_19.ass
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
[Script Info]
; Script generated by Aegisub 0-mod-d5c132a
; http://www.aegisub.org/
Comment: [Processed by 繁化姬 dict-7ac3466c-r881 @ 2019/08/22 15:37:24 | https://zhconvert.org
Title: [Nekomoe kissaten] Uma Musume [14][BDRip].JPSC
ScriptType: v4.00+
WrapStyle: 2
ScaledBorderAndShadow: yes
PlayResX: 1280
PlayResY: 720
YCbCr Matrix: TV.709

[V4+ Styles]
Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding
Style: Dial-CH,Tensentype JiaLiDaYuanGB18030,38,&H00FFFFFF,&H000000FF,&H00000000,&H00000000,0,0,0,0,100,100,0,0,1,1,0,2,10,10,30,1
Style: Dial-CH2,Tensentype JiaLiDaYuanGB18030,36,&H00FFFFFF,&H000000FF,&H00000000,&H00000000,0,0,0,0,100,100,0,0,1,1,0,8,10,10,36,1

[Events]
Format: Laye, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text
Comment: 0,0:00:00.00,0:00:00.00,Staff,,0,0,0,,Staff
Dialogue: 0,0:00:05.00,0:00:13.41,Staff,,0,0,0,,{=0}{\fscy100\t(5,8388,\fscy148.63)\fscx100\t(5,8388,\fscx148.63)\move(640,10,672.24,-73.86,5,8388)\alpha&HFF&\t(0,500,\alpha&H00&)\t(7910,8410,\alpha&HFF&)\blur5}本字幕由喵萌奶茶屋制作 仅供交流试看之用 请勿用于商业用途 \N翻译: Ronny 校对: 雨后飘雪 繁化: SashiharaRino 后期: MIR
Comment: 0,0:00:00.00,0:00:00.00,Staff,,0,0,0,,Title
Dialogue: 0,0:02:03.98,0:02:07.98,Title,,0,0,0,,{\clip(452,502,834,504)\pos(640,570)\c&H99A8F2&}BNW的誓言①
Dialogue: 0,0:02:03.98,0:02:07.98,Title,,0,0,0,,{\clip(452,504,834,506)\pos(640,570)\c&H99A8F2&}BNW的誓言①
24 changes: 24 additions & 0 deletions AssParser.Test/AssParserTest/style_15.ass
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
[Script Info]
; Script generated by Aegisub 0-mod-d5c132a
; http://www.aegisub.org/
Comment: [Processed by 繁化姬 dict-7ac3466c-r881 @ 2019/08/22 15:37:24 | https://zhconvert.org
Title: [Nekomoe kissaten] Uma Musume [14][BDRip].JPSC
ScriptType: v4.00+
WrapStyle: 2
ScaledBorderAndShadow: yes
PlayResX: 1280
PlayResY: 720
YCbCr Matrix: TV.709

[V4+ Styles]
Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding
Styl: Dial-CH,Tensentype JiaLiDaYuanGB18030,38,&H00FFFFFF,&H000000FF,&H00000000,&H00000000,0,0,0,0,100,100,0,0,1,1,0,2,10,10,30,1
Style: Dial-CH2,Tensentype JiaLiDaYuanGB18030,36,&H00FFFFFF,&H000000FF,&H00000000,&H00000000,0,0,0,0,100,100,0,0,1,1,0,8,10,10,36,1

[Events]
Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text
Comment: 0,0:00:00.00,0:00:00.00,Staff,,0,0,0,,Staff
Dialogue: 0,0:00:05.00,0:00:13.41,Staff,,0,0,0,,{=0}{\fscy100\t(5,8388,\fscy148.63)\fscx100\t(5,8388,\fscx148.63)\move(640,10,672.24,-73.86,5,8388)\alpha&HFF&\t(0,500,\alpha&H00&)\t(7910,8410,\alpha&HFF&)\blur5}本字幕由喵萌奶茶屋制作 仅供交流试看之用 请勿用于商业用途 \N翻译: Ronny 校对: 雨后飘雪 繁化: SashiharaRino 后期: MIR
Comment: 0,0:00:00.00,0:00:00.00,Staff,,0,0,0,,Title
Dialogue: 0,0:02:03.98,0:02:07.98,Title,,0,0,0,,{\clip(452,502,834,504)\pos(640,570)\c&H99A8F2&}BNW的誓言①
Dialogue: 0,0:02:03.98,0:02:07.98,Title,,0,0,0,,{\clip(452,504,834,506)\pos(640,570)\c&H99A8F2&}BNW的誓言①

0 comments on commit c22d99d

Please sign in to comment.