41
									
								
								tests/test_get_set_cluster.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										41
									
								
								tests/test_get_set_cluster.c
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,41 @@
 | 
			
		||||
#include <stdint.h>
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
 | 
			
		||||
#include "fat12.h"
 | 
			
		||||
 | 
			
		||||
static uint8_t sample_fat12[] = {
 | 
			
		||||
    0xF0, 0xFF, 0xFF, 0x03, 0x40, 0x00, 0x05, 0x60,
 | 
			
		||||
    0x00, 0x07, 0x80, 0x00, 0xFF, 0xAF, 0x00, 0x14,
 | 
			
		||||
    0xC0, 0x00, 0x0D, 0xE0, 0x00, 0x0F, 0x00, 0x01,
 | 
			
		||||
    0x11, 0xF0, 0xFF, 0x00, 0xF0, 0xFF, 0x15, 0x60,
 | 
			
		||||
    0x01, 0x19, 0x70, 0xFF, 0xF7, 0xAF, 0x01, 0xFF,
 | 
			
		||||
    0x0F, 0x00, 0x00, 0x70, 0xFF, 0x00, 0x00, 0x00,
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
static uint16_t fat12_compare[] = {
 | 
			
		||||
    0xff0, 0xfff, 0x003, 0x004, 0x005, 0x006, 0x007, 0x008,
 | 
			
		||||
    0xfff, 0x00a, 0x014, 0x00c, 0x00d, 0x00e, 0x00f, 0x010,
 | 
			
		||||
    0x011, 0xfff, 0x000, 0xfff, 0x015, 0x016, 0x019, 0xff7,
 | 
			
		||||
    0xff7, 0x01a, 0xfff, 0x000, 0x000, 0xff7, 0x000, 0x000,
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
int main(int argc, char **argv) {
 | 
			
		||||
    int i;
 | 
			
		||||
    uint8_t generated_fat12[sizeof(sample_fat12)];
 | 
			
		||||
 | 
			
		||||
    for (i = 0; i < sizeof(fat12_compare) / sizeof(*fat12_compare); i++) {
 | 
			
		||||
        uint32_t cluster = fat12_get_cluster(sample_fat12, i);
 | 
			
		||||
        fprintf(stderr, "GET: %2d: %03x (%03x) %s\n", i, cluster, fat12_compare[i], cluster == fat12_compare[i] ? "Ok" : "Error");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    for (i = 0; i < sizeof(fat12_compare) / sizeof(*fat12_compare); i++) {
 | 
			
		||||
        fat12_set_cluster(generated_fat12, i, fat12_compare[i]);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    for (i = 0; i < sizeof(sample_fat12) / sizeof(*sample_fat12); i++) {
 | 
			
		||||
        fprintf(stderr, "PUT: %2d: %02x (%02x) %s\n",
 | 
			
		||||
            i,
 | 
			
		||||
            generated_fat12[i], sample_fat12[i],
 | 
			
		||||
            generated_fat12[i] == sample_fat12[i] ? "Ok" : "Error");
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user