package com.noveogroup.android.log;

import org.junit.Assert;
import org.junit.Test;

public class UtilsTest {

    @Test
    public void shortenClassNameTest() {
        Assert.assertEquals(null, Utils.shortenClassName(null, 10));

        String className = "com.noveogroup.SomeClass";
        Assert.assertEquals("*.SomeClass", Utils.shortenClassName(className, -1));
        Assert.assertEquals("*.SomeClass", Utils.shortenClassName(className, 0));
        Assert.assertEquals("*.SomeClass", Utils.shortenClassName(className, 11));
        Assert.assertEquals("*.SomeClass", Utils.shortenClassName(className, 21));
        Assert.assertEquals("*.noveogroup.SomeClass", Utils.shortenClassName(className, 22));
        Assert.assertEquals("*.noveogroup.SomeClass", Utils.shortenClassName(className, 23));
        Assert.assertEquals("com.noveogroup.SomeClass", Utils.shortenClassName(className, 24));
        Assert.assertEquals("com.noveogroup.SomeClass", Utils.shortenClassName(className, Integer.MAX_VALUE));

        String loggerName = "com...Logger";
        Assert.assertEquals("*.Logger", Utils.shortenClassName(loggerName, -1));
        Assert.assertEquals("*.Logger", Utils.shortenClassName(loggerName, 0));
        Assert.assertEquals("*..Logger", Utils.shortenClassName(loggerName, 9));
        Assert.assertEquals("*...Logger", Utils.shortenClassName(loggerName, 10));
        Assert.assertEquals("com...Logger", Utils.shortenClassName(loggerName, 12));
        Assert.assertEquals("com...Logger", Utils.shortenClassName(loggerName, Integer.MAX_VALUE));
    }

    @Test
    public void formatTest() {
        System.out.println(Utils.format("asdasd %% asdasd %nasd %C %M %L", Utils.class, "logger", "tag", Logger.Level.INFO, "message", new Throwable()));
    }

    @Test
    public void format2Test() {
        System.out.println(Utils.format2("asdasd %% asdasd %5.8nasd %C %M{asdasd} %L{} %logger", Utils.class, "logger", "tag", Logger.Level.INFO, "message"));
    }

}

@@ -218,16 +218,19 @@
 me(null,
+ 0,
  10));%0A%0A
@@ -356,24 +356,27 @@
 e(className,
+ 0,
  -1));%0A     
@@ -391,33 +391,46 @@
 t.assertEquals(%22
-*
+com.noveogroup
 .SomeClass%22, Uti
@@ -455,24 +455,27 @@
 e(className,
+ 0,
  0));%0A      
@@ -545,16 +545,20 @@
 ssName, 
+0, -
 11));%0A  
@@ -632,16 +632,20 @@
 ssName, 
+0, -
 21));%0A  
@@ -730,16 +730,20 @@
 ssName, 
+0, -
 22));%0A  
@@ -828,16 +828,20 @@
 ssName, 
+0, -
 23));%0A  
@@ -928,16 +928,20 @@
 ssName, 
+0, -
 24));%0A  
@@ -1023,24 +1023,27 @@
 e(className,
+ 0,
  Integer.MAX
@@ -1171,16 +1171,19 @@
 gerName,
+ 0,
  -1));%0A 
@@ -1202,33 +1202,37 @@
 t.assertEquals(%22
-*
+com..
 .Logger%22, Utils.
@@ -1259,16 +1259,19 @@
 gerName,
+ 0,
  0));%0A  
@@ -1344,16 +1344,20 @@
 erName, 
+0, -
 9));%0A   
@@ -1430,16 +1430,20 @@
 erName, 
+0, -
 10));%0A  
@@ -1519,16 +1519,20 @@
 erName, 
+0, -
 12));%0A  
@@ -1607,16 +1607,19 @@
 gerName,
+ 0,
  Integer
@@ -1643,416 +1643,6 @@
  %7D%0A%0A
-    @Test%0A    public void formatTest() %7B%0A        System.out.println(Utils.format(%22asdasd %25%25 asdasd %25nasd %25C %25M %25L%22, Utils.class, %22logger%22, %22tag%22, Logger.Level.INFO, %22message%22, new Throwable()));%0A    %7D%0A%0A    @Test%0A    public void format2Test() %7B%0A        System.out.println(Utils.format2(%22asdasd %25%25 asdasd %255.8nasd %25C %25M%7Basdasd%7D %25L%7B%7D %25logger%22, Utils.class, %22logger%22, %22tag%22, Logger.Level.INFO, %22message%22));%0A    %7D%0A%0A
 %7D%0A

fix tests