• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2020 Google Inc. All Rights Reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package com.google.turbine.binder;
18 
19 import static com.google.common.truth.Truth.assertThat;
20 import static org.junit.Assert.assertThrows;
21 
22 import com.google.common.collect.ImmutableList;
23 import com.google.common.collect.ImmutableMap;
24 import org.junit.Test;
25 import org.junit.runner.RunWith;
26 import org.junit.runners.JUnit4;
27 
28 @RunWith(JUnit4.class)
29 public class CtSymClassBinderTest {
30   @Test
formatReleaseVersion()31   public void formatReleaseVersion() {
32     ImmutableList.of(5, 6, 7, 8, 9)
33         .forEach(
34             x ->
35                 assertThat(Character.toString(CtSymClassBinder.formatReleaseVersion(x)))
36                     .isEqualTo(String.valueOf(x)));
37     ImmutableMap.of(
38             10, 'A',
39             11, 'B',
40             12, 'C',
41             35, 'Z')
42         .forEach((k, v) -> assertThat(CtSymClassBinder.formatReleaseVersion(k)).isEqualTo(v));
43     ImmutableList.of(4, 36)
44         .forEach(
45             x ->
46                 assertThrows(
47                     Integer.toString(x),
48                     IllegalArgumentException.class,
49                     () -> CtSymClassBinder.formatReleaseVersion(x)));
50   }
51 }
52