1   /**
2    * Logback: the generic, reliable, fast and flexible logging framework for Java.
3    * 
4    * Copyright (C) 2000-2006, QOS.ch
5    * 
6    * This library is free software, you can redistribute it and/or modify it under
7    * the terms of the GNU Lesser General Public License as published by the Free
8    * Software Foundation.
9    */
10  
11  package ch.qos.logback.core.util;
12  
13  import static org.junit.Assert.assertEquals;
14  
15  import org.junit.Test;
16  
17  
18  public class FileSizeTest{
19  
20    static long KB_CO = 1024;
21    static long MB_CO = 1024*1024;
22    static long GB_CO = 1024*MB_CO;
23    
24  
25    @Test
26    public void test() {
27      {
28        FileSize fs = FileSize.valueOf("8");
29        assertEquals(8, fs.getSize());
30      }
31      
32      {
33        FileSize fs = FileSize.valueOf("8 kbs");
34        assertEquals(8*KB_CO, fs.getSize());
35      }
36    
37      {
38        FileSize fs = FileSize.valueOf("8 kb");
39        assertEquals(8*KB_CO, fs.getSize());
40      }
41      
42      {
43        FileSize fs = FileSize.valueOf("12 mb");
44        assertEquals(12*MB_CO, fs.getSize());
45      }
46  
47      {
48        FileSize fs = FileSize.valueOf("5 GBs");
49        assertEquals(5*GB_CO, fs.getSize());
50      }
51  
52    }
53  }