@@ -1758,6 +1758,146 @@ int test_notecard_clearDebugOutputStream_clears_the_debug_log_function_pointer()
1758
1758
return result;
1759
1759
}
1760
1760
1761
+ int test_notecard_setFn_shares_a_memory_allocation_function_pointer ()
1762
+ {
1763
+ int result;
1764
+
1765
+ // Arrange
1766
+ // //////////
1767
+
1768
+ const mallocFn mockMallocFn = reinterpret_cast <mallocFn>(0x19790917 );
1769
+
1770
+ Notecard notecard;
1771
+ noteSetFn_Parameters.reset ();
1772
+
1773
+ // Action
1774
+ // /////////
1775
+
1776
+ notecard.setFn (mockMallocFn, nullptr , nullptr , nullptr );
1777
+
1778
+ // Assert
1779
+ // /////////
1780
+
1781
+ if (noteSetFn_Parameters.mallocfn )
1782
+ {
1783
+ result = 0 ;
1784
+ }
1785
+ else
1786
+ {
1787
+ result = static_cast <int >(' n' + ' o' + ' t' + ' e' + ' c' + ' a' + ' r' + ' d' );
1788
+ std::cout << " \33 [31mFAILED\33 [0m] " << __FILE__ << " :" << __LINE__ << std::endl;
1789
+ std::cout << " \t noteSetFn_Parameters.mallocfn == " << !!noteSetFn_Parameters.mallocfn << " , EXPECTED: not 0 (`nullptr`)" << std::endl;
1790
+ std::cout << " [" ;
1791
+ }
1792
+
1793
+ return result;
1794
+ }
1795
+
1796
+ int test_notecard_setFn_shares_a_memory_deallocation_function_pointer ()
1797
+ {
1798
+ int result;
1799
+
1800
+ // Arrange
1801
+ // //////////
1802
+
1803
+ const freeFn mockFreeFn = reinterpret_cast <freeFn>(0x19790917 );
1804
+
1805
+ Notecard notecard;
1806
+ noteSetFn_Parameters.reset ();
1807
+
1808
+ // Action
1809
+ // /////////
1810
+
1811
+ notecard.setFn (nullptr , mockFreeFn, nullptr , nullptr );
1812
+
1813
+ // Assert
1814
+ // /////////
1815
+
1816
+ if (noteSetFn_Parameters.freefn )
1817
+ {
1818
+ result = 0 ;
1819
+ }
1820
+ else
1821
+ {
1822
+ result = static_cast <int >(' n' + ' o' + ' t' + ' e' + ' c' + ' a' + ' r' + ' d' );
1823
+ std::cout << " \33 [31mFAILED\33 [0m] " << __FILE__ << " :" << __LINE__ << std::endl;
1824
+ std::cout << " \t noteSetFn_Parameters.freefn == " << !!noteSetFn_Parameters.freefn << " , EXPECTED: not 0 (`nullptr`)" << std::endl;
1825
+ std::cout << " [" ;
1826
+ }
1827
+
1828
+ return result;
1829
+ }
1830
+
1831
+ int test_notecard_setFn_shares_a_delay_function_pointer ()
1832
+ {
1833
+ int result;
1834
+
1835
+ // Arrange
1836
+ // //////////
1837
+
1838
+ const delayMsFn mockDelayFn = reinterpret_cast <delayMsFn>(0x19790917 );
1839
+
1840
+ Notecard notecard;
1841
+ noteSetFn_Parameters.reset ();
1842
+
1843
+ // Action
1844
+ // /////////
1845
+
1846
+ notecard.setFn (nullptr , nullptr , mockDelayFn, nullptr );
1847
+
1848
+ // Assert
1849
+ // /////////
1850
+
1851
+ if (noteSetFn_Parameters.delayfn )
1852
+ {
1853
+ result = 0 ;
1854
+ }
1855
+ else
1856
+ {
1857
+ result = static_cast <int >(' n' + ' o' + ' t' + ' e' + ' c' + ' a' + ' r' + ' d' );
1858
+ std::cout << " \33 [31mFAILED\33 [0m] " << __FILE__ << " :" << __LINE__ << std::endl;
1859
+ std::cout << " \t noteSetFn_Parameters.delayfn == " << !!noteSetFn_Parameters.delayfn << " , EXPECTED: not 0 (`nullptr`)" << std::endl;
1860
+ std::cout << " [" ;
1861
+ }
1862
+
1863
+ return result;
1864
+ }
1865
+
1866
+ int test_notecard_setFn_shares_a_millis_function_pointer ()
1867
+ {
1868
+ int result;
1869
+
1870
+ // Arrange
1871
+ // //////////
1872
+
1873
+ const getMsFn mockMillisFn = reinterpret_cast <getMsFn>(0x19790917 );
1874
+
1875
+ Notecard notecard;
1876
+ noteSetFn_Parameters.reset ();
1877
+
1878
+ // Action
1879
+ // /////////
1880
+
1881
+ notecard.setFn (nullptr , nullptr , nullptr , mockMillisFn);
1882
+
1883
+ // Assert
1884
+ // /////////
1885
+
1886
+ if (noteSetFn_Parameters.millisfn )
1887
+ {
1888
+ result = 0 ;
1889
+ }
1890
+ else
1891
+ {
1892
+ result = static_cast <int >(' n' + ' o' + ' t' + ' e' + ' c' + ' a' + ' r' + ' d' );
1893
+ std::cout << " \33 [31mFAILED\33 [0m] " << __FILE__ << " :" << __LINE__ << std::endl;
1894
+ std::cout << " \t noteSetFn_Parameters.millisfn == " << !!noteSetFn_Parameters.millisfn << " , EXPECTED: not 0 (`nullptr`)" << std::endl;
1895
+ std::cout << " [" ;
1896
+ }
1897
+
1898
+ return result;
1899
+ }
1900
+
1761
1901
int test_notecard_setFnI2cMutex_does_not_modify_locking_mutex_func_parameter_value_before_passing_to_note_c ()
1762
1902
{
1763
1903
int result;
@@ -4928,6 +5068,10 @@ int main(void)
4928
5068
{test_notecard_setDebugOutputStream_shares_a_debug_log_function_pointer, " test_notecard_setDebugOutputStream_shares_a_debug_log_function_pointer" },
4929
5069
{test_notecard_setDebugOutputStream_clears_the_debug_log_function_pointer_when_nullptr_is_provided, " test_notecard_setDebugOutputStream_clears_the_debug_log_function_pointer_when_nullptr_is_provided" },
4930
5070
{test_notecard_clearDebugOutputStream_clears_the_debug_log_function_pointer, " test_notecard_clearDebugOutputStream_clears_the_debug_log_function_pointer" },
5071
+ {test_notecard_setFn_shares_a_memory_allocation_function_pointer, " test_notecard_setFn_shares_a_memory_allocation_function_pointer" },
5072
+ {test_notecard_setFn_shares_a_memory_deallocation_function_pointer, " test_notecard_setFn_shares_a_memory_deallocation_function_pointer" },
5073
+ {test_notecard_setFn_shares_a_delay_function_pointer, " test_notecard_setFn_shares_a_delay_function_pointer" },
5074
+ {test_notecard_setFn_shares_a_millis_function_pointer, " test_notecard_setFn_shares_a_millis_function_pointer" },
4931
5075
{test_notecard_setFnI2cMutex_does_not_modify_locking_mutex_func_parameter_value_before_passing_to_note_c, " test_notecard_setFnI2cMutex_does_not_modify_locking_mutex_func_parameter_value_before_passing_to_note_c" },
4932
5076
{test_notecard_setFnI2cMutex_does_not_modify_unlocking_mutex_func_parameter_value_before_passing_to_note_c, " test_notecard_setFnI2cMutex_does_not_modify_unlocking_mutex_func_parameter_value_before_passing_to_note_c" },
4933
5077
{test_notecard_setFnNoteMutex_does_not_modify_locking_mutex_func_parameter_value_before_passing_to_note_c, " test_notecard_setFnNoteMutex_does_not_modify_locking_mutex_func_parameter_value_before_passing_to_note_c" },
0 commit comments