main_test.go 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. // Copyright 2024 The Ebitengine Authors
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. package main
  15. import (
  16. "testing"
  17. )
  18. func TestJavaPackageName(t *testing.T) {
  19. testCases := []struct {
  20. in string
  21. out bool
  22. }{
  23. {
  24. in: "",
  25. out: false,
  26. },
  27. {
  28. in: ".",
  29. out: false,
  30. },
  31. {
  32. in: "com.hajimehoshi.goinovation",
  33. out: true,
  34. },
  35. {
  36. in: "com.hajimehoshi.$goinovation",
  37. out: true,
  38. },
  39. {
  40. in: "com.hajimehoshi..goinovation",
  41. out: false,
  42. },
  43. {
  44. in: "com.hajimehoshi.go-inovation",
  45. out: false,
  46. },
  47. {
  48. in: "com.hajimehoshi.strictfp", // strictfp is a Java keyword.
  49. out: false,
  50. },
  51. {
  52. in: "com.hajimehoshi.null",
  53. out: false,
  54. },
  55. {
  56. in: "com.hajimehoshi.go1inovation",
  57. out: true,
  58. },
  59. {
  60. in: "com.hajimehoshi.1goinovation",
  61. out: false,
  62. },
  63. {
  64. in: "あ.いうえお",
  65. out: true,
  66. },
  67. }
  68. for _, tc := range testCases {
  69. if got, want := isValidJavaPackageName(tc.in), tc.out; got != want {
  70. t.Errorf("isValidJavaPackageName(%q) = %v; want %v", tc.in, got, want)
  71. }
  72. }
  73. }