Changeset 2100 for trunk


Ignore:
Timestamp:
Nov 21, 2012, 1:34:09 AM (7 years ago)
Author:
sam
Message:

core: implement String::Printf() and start working on the unit tests.
I'm gonna commit this right now though I'm not really sure whether Visual
Studio will agree to build va_copy and others.

Location:
trunk
Files:
1 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/Makefile.am

    r2098 r2100  
    4141    $(bullet_sources) \
    4242    \
    43     core/hash.cpp \
     43    core/hash.cpp core/string.cpp \
    4444    \
    4545    thread/threadbase.h thread/thread.h \
  • trunk/src/lol/core/string.h

    r2096 r2100  
    7171    }
    7272
    73     inline String operator +=(String const &s)
     73    inline String& operator +=(String const &s)
    7474    {
    7575        /* Be careful, we have a trailing zero we don't want! */
     
    8585    }
    8686
    87     inline String operator +=(char c)
     87    inline String& operator +=(char c)
    8888    {
    8989        ((Super &)*this).Last() = c;
     
    108108        return !(*this == s);
    109109    }
     110
     111#ifdef __GNUC__
     112#   define LOL_FMT_ATTR(n, p) __attribute__((format(printf, n, p)))
     113#else
     114#   define LOL_FMT_ATTR(n, p)
     115#endif
     116    static String Printf(char const *format, ...) LOL_FMT_ATTR(1, 2);
     117#undef LOL_FMT_ATTR
    110118};
    111119
  • trunk/src/lolcore.vcxproj

    r2097 r2100  
    236236    <ClCompile Include="camera.cpp" />
    237237    <ClCompile Include="core\hash.cpp" />
     238    <ClCompile Include="core\string.cpp" />
    238239    <ClCompile Include="debug\fps.cpp" />
    239240    <ClCompile Include="debug\record.cpp" />
  • trunk/src/lolcore.vcxproj.filters

    r2077 r2100  
    1212      <UniqueIdentifier>{e056731c-5484-434a-965e-801c199c0366}</UniqueIdentifier>
    1313    </Filter>
     14    <Filter Include="src\core">
     15      <UniqueIdentifier>{a63b1fd6-3747-4a9f-9bd7-3f942133ad6b}</UniqueIdentifier>
     16    </Filter>
    1417    <Filter Include="src\platform">
    1518      <UniqueIdentifier>{a11c55f8-8e10-4270-be24-38e8d4fcf589}</UniqueIdentifier>
     
    180183    </ClCompile>
    181184    <ClCompile Include="hash.cpp">
    182       <Filter>src\...</Filter>
     185      <Filter>src\core</Filter>
     186    </ClCompile>
     187    <ClCompile Include="string.cpp">
     188      <Filter>src\core</Filter>
    183189    </ClCompile>
    184190    <ClCompile Include="layer.cpp">
  • trunk/test/unit/string.cpp

    r2096 r2100  
    121121        LOLUNIT_ASSERT(!(s1 != s3));
    122122    }
     123
     124    LOLUNIT_TEST(StringPrintf)
     125    {
     126        String s1 = "3a";
     127        String s2 = String::Printf("%d%x", 3, 10);
     128
     129        LOLUNIT_ASSERT(s1 == s2);
     130    }
    123131};
    124132
Note: See TracChangeset for help on using the changeset viewer.