//
//  TestOmGrid.m
//  OminoGobo
//
//  Created by David Van Brink on 1/7/14.
//  Copyright (c) 2014 omino. All rights reserved.
//

#import "TestOmGrid.h"
#import "OmGrid.h"
#import "OmTestView.h"

@implementation TestOmGrid

-(int)testBasicNoMargin
{
    OmGrid *og = [OmGrid grid:CGRectMake(0,0,100,100) margin:0 xInPixels:NO xDimension:10 yInPixels:NO yDimension:20];
    
    CGRect cell00 = [og rectAtX:3 y:7];
    
    ASSERT_EQUALS_FLOAT(30 , cell00.origin.x, "cellX?");
    ASSERT_EQUALS_FLOAT(35 , cell00.origin.y, "cellY?");
    ASSERT_EQUALS_FLOAT(10 , cell00.size.width, "width?");
    ASSERT_EQUALS_FLOAT(5 , cell00.size.height, "width?");
    return 0;
}

-(int)testBasicWithMargin
{
    OmGrid *og = [OmGrid grid:CGRectMake(0,0,100,100) margin:10 xInPixels:NO xDimension:2 yInPixels:NO yDimension:3];
    
    CGRect cell00 = [og rectAtX:1 y:1];
    
    ASSERT_EQUALS_FLOAT(55 , cell00.origin.x, "cellX?");
    ASSERT_EQUALS_FLOAT(35 , cell00.size.width, "width?");

    ASSERT_EQUALS_FLOAT(40 , cell00.origin.y, "cellY?");
    ASSERT_EQUALS_FLOAT(20, cell00.size.height, "width?");
    return 0;
}

-(void)testCellByIndex
{
    OmGrid *og = [OmGrid grid:CGRectMake(0,0,100,100) margin:0 xInPixels:NO xDimension:10 yInPixels:NO yDimension:10];
    
    CGRect cell00 = [og cell:0];
    ASSERT_EQUALS_FLOAT(0 , cell00.origin.x, "cellX?");
    ASSERT_EQUALS_FLOAT(0 , cell00.origin.y, "cellY?");
    ASSERT_EQUALS_FLOAT(10 , cell00.size.width, "width?");
    ASSERT_EQUALS_FLOAT(10, cell00.size.height, "width?");

    
    cell00 = [og cell:37];
    ASSERT_EQUALS_FLOAT(70 , cell00.origin.x, "cellX?");
    ASSERT_EQUALS_FLOAT(30 , cell00.origin.y, "cellY?");
    ASSERT_EQUALS_FLOAT(10 , cell00.size.width, "width?");
    ASSERT_EQUALS_FLOAT(10, cell00.size.height, "width?");

}

@end
