예제 #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void mustThrowWhenParsingUnitBeforeValue()
        internal virtual void MustThrowWhenParsingUnitBeforeValue()
        {
            assertThrows(typeof(System.ArgumentException), () => ByteUnit.parse("MiB 1"));
        }
예제 #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void mustThrowWhenParsingOnlyUnit()
        internal virtual void MustThrowWhenParsingOnlyUnit()
        {
            assertThrows(typeof(System.ArgumentException), () => ByteUnit.parse("MiB"));
        }
예제 #3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void mustThrowWhenParsingUnitInterjectedWithNumber()
        internal virtual void MustThrowWhenParsingUnitInterjectedWithNumber()
        {
            assertThrows(typeof(System.ArgumentException), () => ByteUnit.parse("1K2i3B"));
        }
예제 #4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void mustThrowWhenParsingNonNumericTest()
        internal virtual void MustThrowWhenParsingNonNumericTest()
        {
            assertThrows(typeof(System.ArgumentException), () => ByteUnit.parse("abc"));
        }
예제 #5
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void unitsAsBytes()
        internal virtual void UnitsAsBytes()
        {
            assertThat(ByteUnit.bytes(1), @is(1L));
            assertThat(ByteUnit.kibiBytes(1), @is(1024L));
            assertThat(ByteUnit.mebiBytes(1), @is(1048576L));
            assertThat(ByteUnit.gibiBytes(1), @is(1073741824L));
            assertThat(ByteUnit.tebiBytes(1), @is(1099511627776L));
            assertThat(ByteUnit.pebiBytes(1), @is(1125899906842624L));
            assertThat(ByteUnit.exbiBytes(1), @is(1152921504606846976L));

            assertThat(ByteUnit.parse("1"), @is(1L));
            assertThat(ByteUnit.parse("1 KiB"), @is(1024L));
            assertThat(ByteUnit.parse("1KiB"), @is(1024L));
            assertThat(ByteUnit.parse(" 1    Ki B"), @is(1024L));
            assertThat(ByteUnit.parse("1 KB"), @is(1024L));
            assertThat(ByteUnit.parse("1KB"), @is(1024L));
            assertThat(ByteUnit.parse(" 1    KB "), @is(1024L));
            assertThat(ByteUnit.parse("1 kB"), @is(1024L));
            assertThat(ByteUnit.parse("1kB"), @is(1024L));
            assertThat(ByteUnit.parse(" 1    kB "), @is(1024L));
            assertThat(ByteUnit.parse("1 kb"), @is(1024L));
            assertThat(ByteUnit.parse("1kb"), @is(1024L));
            assertThat(ByteUnit.parse(" 1    kb "), @is(1024L));
            assertThat(ByteUnit.parse("1 k"), @is(1024L));
            assertThat(ByteUnit.parse("1k"), @is(1024L));
            assertThat(ByteUnit.parse(" 1    k"), @is(1024L));
            assertThat(ByteUnit.parse("1 MiB"), @is(1048576L));
            assertThat(ByteUnit.parse("1MiB"), @is(1048576L));
            assertThat(ByteUnit.parse(" 1    Mi B"), @is(1048576L));
            assertThat(ByteUnit.parse("1 MB"), @is(1048576L));
            assertThat(ByteUnit.parse("1MB"), @is(1048576L));
            assertThat(ByteUnit.parse(" 1    MB "), @is(1048576L));
            assertThat(ByteUnit.parse("1 mB"), @is(1048576L));
            assertThat(ByteUnit.parse("1mB"), @is(1048576L));
            assertThat(ByteUnit.parse(" 1    mB "), @is(1048576L));
            assertThat(ByteUnit.parse("1 mb"), @is(1048576L));
            assertThat(ByteUnit.parse("1mb"), @is(1048576L));
            assertThat(ByteUnit.parse(" 1    mb "), @is(1048576L));
            assertThat(ByteUnit.parse("1 m"), @is(1048576L));
            assertThat(ByteUnit.parse("1m"), @is(1048576L));
            assertThat(ByteUnit.parse(" 1    m"), @is(1048576L));
            assertThat(ByteUnit.parse("1 GiB"), @is(1073741824L));
            assertThat(ByteUnit.parse("1GiB"), @is(1073741824L));
            assertThat(ByteUnit.parse(" 1    Gi B"), @is(1073741824L));
            assertThat(ByteUnit.parse("1 GB"), @is(1073741824L));
            assertThat(ByteUnit.parse("1GB"), @is(1073741824L));
            assertThat(ByteUnit.parse(" 1    GB "), @is(1073741824L));
            assertThat(ByteUnit.parse("1 gB"), @is(1073741824L));
            assertThat(ByteUnit.parse("1gB"), @is(1073741824L));
            assertThat(ByteUnit.parse(" 1    gB "), @is(1073741824L));
            assertThat(ByteUnit.parse("1 gb"), @is(1073741824L));
            assertThat(ByteUnit.parse("1gb"), @is(1073741824L));
            assertThat(ByteUnit.parse(" 1    gb "), @is(1073741824L));
            assertThat(ByteUnit.parse("1 g"), @is(1073741824L));
            assertThat(ByteUnit.parse("1g"), @is(1073741824L));
            assertThat(ByteUnit.parse(" 1    g"), @is(1073741824L));
            assertThat(ByteUnit.parse("1 TiB"), @is(1099511627776L));
            assertThat(ByteUnit.parse("1TiB"), @is(1099511627776L));
            assertThat(ByteUnit.parse(" 1    Ti B"), @is(1099511627776L));
            assertThat(ByteUnit.parse("1 TB"), @is(1099511627776L));
            assertThat(ByteUnit.parse("1TB"), @is(1099511627776L));
            assertThat(ByteUnit.parse(" 1    TB "), @is(1099511627776L));
            assertThat(ByteUnit.parse("1 PiB"), @is(1125899906842624L));
            assertThat(ByteUnit.parse("1PiB"), @is(1125899906842624L));
            assertThat(ByteUnit.parse(" 1    Pi B"), @is(1125899906842624L));
            assertThat(ByteUnit.parse("1 PB"), @is(1125899906842624L));
            assertThat(ByteUnit.parse("1PB"), @is(1125899906842624L));
            assertThat(ByteUnit.parse(" 1    PB "), @is(1125899906842624L));
            assertThat(ByteUnit.parse("1 EiB"), @is(1152921504606846976L));
            assertThat(ByteUnit.parse("1EiB"), @is(1152921504606846976L));
            assertThat(ByteUnit.parse(" 1    Ei B"), @is(1152921504606846976L));
            assertThat(ByteUnit.parse("1 EB"), @is(1152921504606846976L));
            assertThat(ByteUnit.parse("1EB"), @is(1152921504606846976L));
            assertThat(ByteUnit.parse(" 1    EB "), @is(1152921504606846976L));
        }