Преглед изворни кода

Renamed the peak function to the correct spelling peek.

Bart Hertog пре 5 година
родитељ
комит
db1b94698b

+ 1 - 1
src/ReadBufferInterface.h

@@ -62,7 +62,7 @@ namespace EmbeddedProto
           \param[out] byte When the buffer is not empty this variable will hold the oldest value.
           \return True when the buffer was not empty.
       */
-      virtual bool peak(uint8_t& byte) const = 0;
+      virtual bool peek(uint8_t& byte) const = 0;
 
       //! Advances the internal read index by one when the buffer is not empty.
       virtual void advance() = 0;

+ 2 - 2
src/ReadBufferSection.cpp

@@ -54,12 +54,12 @@ namespace EmbeddedProto
     return max_size_;
   }
 
-  bool ReadBufferSection::peak(uint8_t& byte) const
+  bool ReadBufferSection::peek(uint8_t& byte) const
   {
     bool result = 0 < size_;
     if(result)
     {
-      result = buffer_.peak(byte);
+      result = buffer_.peek(byte);
     }
     return result;
   }

+ 1 - 1
src/ReadBufferSection.h

@@ -76,7 +76,7 @@ namespace EmbeddedProto
       /*!
         This will not do anything if size zero is reached.
       */
-      bool peak(uint8_t& byte) const override;
+      bool peek(uint8_t& byte) const override;
 
       //! Decrement the size and call advance on the parent buffer.
       /*!

+ 2 - 3
test/mock/ReadBufferMock.h

@@ -45,9 +45,8 @@ namespace Mocks
       MOCK_CONST_METHOD0(get_size, uint32_t());
       MOCK_CONST_METHOD0(get_max_size, uint32_t());
       
-      MOCK_CONST_METHOD1(peak, bool(uint8_t&));
-      MOCK_CONST_METHOD0(peak, uint8_t());
-
+      MOCK_CONST_METHOD1(peek, bool(uint8_t&));
+      
       MOCK_METHOD0(advance, void());
       MOCK_METHOD1(advance, void(uint32_t));
       

+ 4 - 4
test/test_ReadBufferSection.cpp

@@ -67,12 +67,12 @@ TEST(ReadBufferSection, peek)
 {
   Mocks::ReadBufferMock read_buffer_mock;
   EXPECT_CALL(read_buffer_mock, get_size()).WillRepeatedly(Return(1));
-  EXPECT_CALL(read_buffer_mock, peak(_)).WillOnce(DoAll(SetArgReferee<0>(1), Return(true)));
+  EXPECT_CALL(read_buffer_mock, peek(_)).WillOnce(DoAll(SetArgReferee<0>(1), Return(true)));
 
   EmbeddedProto::ReadBufferSection read_buffer_section(read_buffer_mock, 1);
   
   uint8_t byte = 0;
-  EXPECT_TRUE(read_buffer_section.peak(byte));
+  EXPECT_TRUE(read_buffer_section.peek(byte));
   EXPECT_EQ(1, byte);
 }
 
@@ -135,12 +135,12 @@ TEST(ReadBufferSection, pop)
   EXPECT_EQ(1, byte);
   EXPECT_EQ(0, read_buffer_section.get_size());
 
-  // When attempting to read or peak at more we should not change byte and get a false.
+  // When attempting to read or peek at more we should not change byte and get a false.
   byte = 0;
   EXPECT_FALSE(read_buffer_section.pop(byte));
   EXPECT_EQ(0, byte);
   EXPECT_EQ(0, read_buffer_section.get_size());
-  EXPECT_FALSE(read_buffer_section.peak(byte));
+  EXPECT_FALSE(read_buffer_section.peek(byte));
   EXPECT_EQ(0, byte);
 }