@@ -12,7 +12,8 @@ class VerifyBorders_HeapBlockDevice : public mbed::HeapBlockDevice {
1212 mutable bd_size_t upper_limit;
1313
1414 VerifyBorders_HeapBlockDevice (bd_size_t size)
15- : HeapBlockDevice(size) {
15+ : HeapBlockDevice(size)
16+ {
1617 borders_crossed = false ;
1718 lower_limit = 0 ;
1819 upper_limit = size;
@@ -21,21 +22,21 @@ class VerifyBorders_HeapBlockDevice : public mbed::HeapBlockDevice {
2122 virtual bool is_valid_read (bd_addr_t addr, bd_size_t size) const
2223 {
2324 borders_crossed |= addr < lower_limit;
24- borders_crossed |= addr+ size > upper_limit;
25+ borders_crossed |= addr + size > upper_limit;
2526 return BlockDevice::is_valid_read (addr, size);
2627 }
2728
2829 virtual bool is_valid_program (bd_addr_t addr, bd_size_t size) const
2930 {
3031 borders_crossed |= addr < lower_limit;
31- borders_crossed |= addr+ size > upper_limit;
32+ borders_crossed |= addr + size > upper_limit;
3233 return BlockDevice::is_valid_program (addr, size);
3334 }
3435
3536 virtual bool is_valid_erase (bd_addr_t addr, bd_size_t size) const
3637 {
3738 borders_crossed |= addr < lower_limit;
38- borders_crossed |= addr+ size > upper_limit;
39+ borders_crossed |= addr + size > upper_limit;
3940 return BlockDevice::is_valid_erase (addr, size);
4041 }
4142};
@@ -51,7 +52,7 @@ class SlicingBlockModuleTest : public testing::Test {
5152 magic = new uint8_t [BLOCK_SIZE];
5253 buf = new uint8_t [BLOCK_SIZE];
5354 // Generate simple pattern to verify against
54- for (int i= 0 ; i < BLOCK_SIZE; i++) {
55+ for (int i = 0 ; i < BLOCK_SIZE; i++) {
5556 magic[i] = 0xaa + i;
5657 }
5758 }
@@ -77,20 +78,20 @@ TEST_F(SlicingBlockModuleTest, constructor)
7778
7879TEST_F (SlicingBlockModuleTest, slice_in_middle)
7980{
80- uint8_t *program = new uint8_t [BLOCK_SIZE]{0xbb ,0xbb ,0xbb };
81+ uint8_t *program = new uint8_t [BLOCK_SIZE] {0xbb ,0xbb ,0xbb };
8182
8283 // Write magic value to heap block before and after the space for slice
8384 bd.program (magic, 0 , BLOCK_SIZE);
84- bd.program (magic, BLOCK_SIZE* 3 , BLOCK_SIZE);
85+ bd.program (magic, BLOCK_SIZE * 3 , BLOCK_SIZE);
8586
86- bd.upper_limit = BLOCK_SIZE* 3 ;
87+ bd.upper_limit = BLOCK_SIZE * 3 ;
8788 bd.lower_limit = BLOCK_SIZE;
8889 bd.borders_crossed = false ;
8990
9091 // Skip first block, then create sclicing device, with size of 2 blocks
91- mbed::SlicingBlockDevice slice (&bd, BLOCK_SIZE, BLOCK_SIZE* 3 );
92+ mbed::SlicingBlockDevice slice (&bd, BLOCK_SIZE, BLOCK_SIZE * 3 );
9293 EXPECT_EQ (slice.init (), BD_ERROR_OK);
93- EXPECT_EQ (BLOCK_SIZE* 2 , slice.size ());
94+ EXPECT_EQ (BLOCK_SIZE * 2 , slice.size ());
9495 EXPECT_EQ (bd.borders_crossed , false );
9596
9697 // Program a test value
@@ -101,44 +102,44 @@ TEST_F(SlicingBlockModuleTest, slice_in_middle)
101102 // Verify that blocks before and after the slicing blocks are not touched
102103 bd.read (buf, 0 , BLOCK_SIZE);
103104 EXPECT_EQ (0 , memcmp (buf, magic, BLOCK_SIZE));
104- bd.read (buf, BLOCK_SIZE* 3 , BLOCK_SIZE);
105+ bd.read (buf, BLOCK_SIZE * 3 , BLOCK_SIZE);
105106 EXPECT_EQ (0 , memcmp (buf, magic, BLOCK_SIZE));
106107}
107108
108109TEST_F (SlicingBlockModuleTest, slice_at_the_end)
109110{
110- uint8_t *program = new uint8_t [BLOCK_SIZE]{0xbb ,0xbb ,0xbb };
111+ uint8_t *program = new uint8_t [BLOCK_SIZE] {0xbb ,0xbb ,0xbb };
111112
112113 // Write magic value to heap block before the space for slice
113114 // our bd is 10*BLOCK_SIZE, so sector 7
114- bd.program (magic, BLOCK_SIZE* 7 , BLOCK_SIZE);
115+ bd.program (magic, BLOCK_SIZE * 7 , BLOCK_SIZE);
115116
116117 // Screate sclicing device, with size of 2 blocks
117118 // Use negative index
118119 mbed::SlicingBlockDevice slice (&bd, -BLOCK_SIZE*2 );
119120 EXPECT_EQ (slice.init (), BD_ERROR_OK);
120- EXPECT_EQ (BLOCK_SIZE* 2 , slice.size ());
121+ EXPECT_EQ (BLOCK_SIZE * 2 , slice.size ());
121122
122123 // Program a test value
123124 EXPECT_EQ (slice.program (program, 0 , BLOCK_SIZE), BD_ERROR_OK);
124125 EXPECT_EQ (slice.program (program, BLOCK_SIZE, BLOCK_SIZE), BD_ERROR_OK);
125126
126127 // Verify that blocks before and after the slicing blocks are not touched
127- bd.read (buf, BLOCK_SIZE* 7 , BLOCK_SIZE);
128+ bd.read (buf, BLOCK_SIZE * 7 , BLOCK_SIZE);
128129 EXPECT_EQ (0 , memcmp (buf, magic, BLOCK_SIZE));
129130}
130131
131132TEST_F (SlicingBlockModuleTest, over_write)
132133{
133- uint8_t *program = new uint8_t [BLOCK_SIZE]{0xbb ,0xbb ,0xbb };
134+ uint8_t *program = new uint8_t [BLOCK_SIZE] {0xbb ,0xbb ,0xbb };
134135
135136 // Screate sclicing device, with size of 2 blocks
136- mbed::SlicingBlockDevice slice (&bd, BLOCK_SIZE, BLOCK_SIZE* 3 );
137+ mbed::SlicingBlockDevice slice (&bd, BLOCK_SIZE, BLOCK_SIZE * 3 );
137138 EXPECT_EQ (slice.init (), BD_ERROR_OK);
138139
139140 EXPECT_EQ (slice.program (program, 0 , BLOCK_SIZE), BD_ERROR_OK);
140141 EXPECT_EQ (slice.program (program, BLOCK_SIZE, BLOCK_SIZE), BD_ERROR_OK);
141142 // Program a test value to address that is one pass the device size
142- EXPECT_EQ (slice.program (program, 2 * BLOCK_SIZE, BLOCK_SIZE), BD_ERROR_DEVICE_ERROR);
143+ EXPECT_EQ (slice.program (program, 2 * BLOCK_SIZE, BLOCK_SIZE), BD_ERROR_DEVICE_ERROR);
143144
144145}
0 commit comments