chs_cht_changer_test.go 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. package chs_cht_changer
  2. import (
  3. "path/filepath"
  4. "testing"
  5. "github.com/allanpk716/ChineseSubFinder/pkg/change_file_encode"
  6. "github.com/allanpk716/ChineseSubFinder/pkg/unit_test_helper"
  7. )
  8. func TestProcess(t *testing.T) {
  9. rootDir := unit_test_helper.GetTestDataResourceRootPath([]string{"sub_chs_cht_changer"}, 4, true)
  10. type args struct {
  11. srcSubFileFPath string
  12. desChineseLanguageType int
  13. }
  14. tests := []struct {
  15. name string
  16. args args
  17. wantErr bool
  18. }{
  19. {name: "0", args: args{
  20. srcSubFileFPath: filepath.Join(rootDir, "神枪手 (2021) 1080p DTSHD-MA.chinese(繁英,subhd).srt"),
  21. desChineseLanguageType: 0,
  22. }, wantErr: false},
  23. {name: "1", args: args{
  24. srcSubFileFPath: filepath.Join(rootDir, "机动战士Z高达:星之继承者 (2005) 1080p TrueHD.chinese(繁).ssa"),
  25. desChineseLanguageType: 0,
  26. }, wantErr: false},
  27. {name: "2", args: args{
  28. srcSubFileFPath: filepath.Join(rootDir, "机动战士Z高达Ⅲ:星辰的鼓动是爱 (2006) 1080p TrueHD.chinese(繁).ass"),
  29. desChineseLanguageType: 0,
  30. }, wantErr: false},
  31. {name: "3", args: args{
  32. srcSubFileFPath: filepath.Join(rootDir, "Better Call Saul - S06E04 - Hit and Run WEBDL-1080p.chinese(简,shooter).srt"),
  33. desChineseLanguageType: 1,
  34. }, wantErr: false},
  35. {name: "4", args: args{
  36. srcSubFileFPath: filepath.Join(rootDir, "Better Call Saul - S06E04 - Hit and Run WEBDL-1080p.chinese(简英,shooter).ass"),
  37. desChineseLanguageType: 1,
  38. }, wantErr: false},
  39. }
  40. for _, tt := range tests {
  41. t.Run(tt.name, func(t *testing.T) {
  42. err := change_file_encode.Process(tt.args.srcSubFileFPath, 0)
  43. if err != nil {
  44. t.Errorf("change_file_encode.Process() error = %v, wantErr %v", err, tt.wantErr)
  45. }
  46. if err = Process(tt.args.srcSubFileFPath, tt.args.desChineseLanguageType); (err != nil) != tt.wantErr {
  47. t.Errorf("Process() error = %v, wantErr %v", err, tt.wantErr)
  48. }
  49. })
  50. }
  51. }