/*
 *     Copyright (C) 2015  higherfrequencytrading.com
 *
 *     This program is free software: you can redistribute it and/or modify
 *     it under the terms of the GNU Lesser General Public License as published by
 *     the Free Software Foundation, either version 3 of the License.
 *
 *     This program is distributed in the hope that it will be useful,
 *     but WITHOUT ANY WARRANTY; without even the implied warranty of
 *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *     GNU Lesser General Public License for more details.
 *
 *     You should have received a copy of the GNU Lesser General Public License
 *     along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package net.openhft.chronicle.core;

import org.junit.Ignore;
import org.junit.Test;

import java.io.File;
import java.io.RandomAccessFile;
import java.nio.channels.FileChannel;

public class OSTest {
    @Test
    public void testIs64Bit() {
        System.out.println("is64 = " + OS.is64Bit());
    }

    @Test
    public void testGetProcessId() {
        System.out.println("pid = " + OS.getProcessId());
    }

    @Test
    @Ignore("Should always pass, or crash the JVM based on length")
    public void testMap()            throws Exception {
        if (!OS.isWindows()) return;

        // crashes the JVM.
//        long length = (4L << 30L) + (64 << 10);
        // doesn't crash the JVM.
        long length = (4L << 30L);

        String name = OS.TARGET + "/deleteme";
        new File(name).deleteOnExit();
        FileChannel fc = new RandomAccessFile(name, "rw").getChannel();
        long address = OS.map0(fc, OS.imodeFor(FileChannel.MapMode.READ_WRITE), 0, length);
        for (long offset = 0; offset < length; offset += OS.pageSize())
            OS.memory().writeLong(address + offset, offset);
        OS.unmap(address, length);
    }
}
@@ -898,16 +898,62 @@
 annel;%0A%0A
+import static org.junit.Assert.assertEquals;%0A%0A
 public c
@@ -1173,32 +1173,695 @@
 ssId());%0A    %7D%0A%0A
+    @Test%0A    public void testMapGranularity() throws Exception %7B%0A        // tests that windows supports page mapping granularity%0A        long length = OS.pageSize();%0A        String name = OS.TARGET + %22/deleteme%22;%0A        File file = new File(name);%0A        file.deleteOnExit();%0A        FileChannel fc = new RandomAccessFile(name, %22rw%22).getChannel();%0A        long address = OS.map0(fc, OS.imodeFor(FileChannel.MapMode.READ_WRITE), 0, length);%0A        for (long offset = 0; offset %3C length; offset += OS.pageSize())%0A            OS.memory().writeLong(address + offset, offset);%0A        OS.unmap(address, length);%0A        assertEquals(length, file.length());%0A    %7D%0A%0A
     @Test%0A    @I

Add a map granularity test