/*
 * Copyright 2013 Jin Kwon <jinahya at gmail.com>.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.github.jinahya.codec;

import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.Test;

import java.util.UUID;

import static com.github.jinahya.codec.IdCodecBase.RADIX_MAXIMUM;
import static com.github.jinahya.codec.IdCodecBase.RADIX_MINIMUM;
import static com.github.jinahya.codec.IdCodecBase.SCALE_MAXIMUM;
import static com.github.jinahya.codec.IdCodecBase.SCALE_MINIMUM;
import static java.util.UUID.randomUUID;
import static java.util.concurrent.ThreadLocalRandom.current;
import static org.junit.jupiter.api.Assertions.assertEquals;

@Slf4j
class IdCodecTest {

    /**
     * Tests {@link IdEncoder#encode(long)} method and {@link IdDecoder#decode(String)} method.
     */
    @Test
    void encodeDecodeLong() {
        final IdEncoder encoder = new IdEncoder();
        final IdDecoder decoder = new IdDecoder();
        for (int scale = SCALE_MINIMUM; scale <= SCALE_MAXIMUM; scale++) {
            encoder.scale(scale);
            decoder.scale(scale);
            for (int radix = RADIX_MINIMUM; radix <= RADIX_MAXIMUM; radix++) {
                encoder.radix(radix);
                decoder.radix(radix);
                final long expected = current().nextLong();
                final String encoded = encoder.encode(expected);
                final long actual = decoder.decode(encoded);
                log.debug("scale: {}", scale);
                log.debug("radix: {}", radix);
                log.debug("expected: {}", expected);
                log.debug("encoded: {}", encoded);
                log.debug("actual: {}", actual);
                assertEquals(expected, actual);
            }
        }
    }

    /**
     * Tests {@link IdEncoder#encodeUuid(UUID)} method and {@link IdDecoder#decodeUuid(String)} method.
     */
    @Test
    void encodeDecodeUuid() {
        final IdEncoder encoder = new IdEncoder();
        final IdDecoder decoder = new IdDecoder();
        for (int scale = SCALE_MINIMUM; scale <= SCALE_MAXIMUM; scale++) {
            encoder.scale(scale);
            decoder.scale(scale);
            for (int radix = RADIX_MINIMUM; radix <= RADIX_MAXIMUM; radix++) {
                encoder.radix(radix);
                decoder.radix(radix);
                final UUID expected = randomUUID();
                final String encoded = encoder.encodeUuid(expected);
                final UUID actual = decoder.decodeUuid(encoded);
                log.debug("scale: {}", scale);
                log.debug("radix: {}", radix);
                log.debug("expected: {}", expected);
                log.debug("encoded: {}", encoded);
                log.debug("actual: {}", actual);
                assertEquals(expected, actual);
            }
        }
    }
}

@@ -1926,32 +1926,34 @@
 ecode(encoded);%0A
+//
                 
@@ -1975,32 +1975,34 @@
 e: %7B%7D%22, scale);%0A
+//
                 
@@ -2024,32 +2024,34 @@
 x: %7B%7D%22, radix);%0A
+//
                 
@@ -2079,32 +2079,34 @@
 %7B%7D%22, expected);%0A
+//
                 
@@ -2132,32 +2132,34 @@
  %7B%7D%22, encoded);%0A
+//
                 
@@ -3008,32 +3008,34 @@
 eUuid(encoded);%0A
+//
                 
@@ -3057,32 +3057,34 @@
 e: %7B%7D%22, scale);%0A
+//
                 
@@ -3106,32 +3106,34 @@
 x: %7B%7D%22, radix);%0A
+//
                 
@@ -3161,32 +3161,34 @@
 %7B%7D%22, expected);%0A
+//
                 
@@ -3218,24 +3218,26 @@
 , encoded);%0A
+//
             

Comment out some debugging statements