- 1
#define xxx 1 ? 2 : 3
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+151
#define xxx 1 ? 2 : 3
+151
#include "stdafx.h"
class CTest
{
private:
virtual void Print()
{
_tprintf( _T("He he ;)\n"));
}
};
class CX
{
public:
virtual void BlaBla();
};
int _tmain(int argc, _TCHAR* argv[])
{
CTest t;
//error C2248: 'CTest::Print' : cannot access private member declared in class 'test'
//t.Print();
//It works
((void (*)(void))((int*)(*(int*)&t))[0])();
//It works, too
((CX*)&t)->BlaBla();
return 0;
}
+140.5
#include <numeric>
#include <algorithm>
#include <iostream>
#include <functional>
#include <boost/iterator/counting_iterator.hpp>
int main()
{
std::cout << std::accumulate(boost::make_counting_iterator(2), boost::make_counting_iterator(8), 1, std::multiplies<int>());
return 0;
}
+182.7
...
char hex[16];
int i;
for (i = 1; i<=len; i++)
{
hex[1]="0";hex[2]="1";hex[3]="2";hex[4]="3";
hex[5]="4";hex[6]="5";hex[7]="6";hex[8]="7";
hex[9]="8";hex[10]="9";hex[11]="A";hex[12]="B";
hex[13]="C";hex[14]="D";hex[15]="E";hex[16]="F";
printf ("%c", hex[buff[i-1]>>4<<4/16-1]);
printf ("%c", hex[buff[i-1]>>4<<4 ^ buff[i-1]-1]);}
...
потрясающий вывод чисел в 16-й системе счисления. родители девушки похоже наиболее яркие представители Индии и Китая...
+183
if( picturesArray.count() == 0 )
{
int i = 0;
++i;
return;
}
+242.5
CNode* CBSTree::AddNode(CNode *&pTree, CNode *pNode)
{
...
return !NULL;
}
...
if(AddNode(pTree->left ,pNode)!=NULL)
{
...
}
...
Надо не нулл - дадим не нулл!
+159.6
//Make the Ahem font antialias correctly on Acid3
String nameStr(fullName.get());
m_allowFontSmoothing = (nameStr != "Ahem");
Правильное сглаживание шрифтов в ACID3. WebKit.
Отсюда: http://habrahabr.ru/blogs/code_wtf/50744/
+154.3
double a, b;
...
*((DWORD*)&a) ^= *((DWORD*)&b);
*((DWORD*)&b) ^= *((DWORD*)&a);
*((DWORD*)&a) ^= *((DWORD*)&b);
*((DWORD*)&a + 1) ^= *((DWORD*)&b + 1);
*((DWORD*)&b + 1) ^= *((DWORD*)&a + 1);
*((DWORD*)&a + 1) ^= *((DWORD*)&b + 1);
Cпособ обменять значения двух переменных типа double;
+164.3
int _I_ = 0;
if (x > GetConstVal ())
_I_ = 1;
int ka = (_I_) * k;
int kaka = (_I_); //Это случайно получилось :(
Просто просится наложить...
+155
void SimpleTest::testTrivial() {
wxTst::TempInteractive interactive;
wxTst::ModalDialogTimer timer(wxID_OK);
// *** Loop up top level containers ***
CPPUNIT_ASSERT_MESSAGE ("Application top window invalid",
wxTheApp->GetTopWindow () != NULL);
wxMDIParentFrame *topFrame =
dynamic_cast< wxMDIParentFrame * >(wxTheApp->GetTopWindow ());
CPPUNIT_ASSERT_MESSAGE ("Top window is not an MDI Parent frame",
topFrame != NULL);
wxMenuBar *menuBar = topFrame->GetMenuBar ();
CPPUNIT_ASSERT_MESSAGE ("Menubar not found", menuBar != NULL);
// interactive.ShowCurrentGui (_T(__FILE__), __LINE__);
// *** Check menu item ***
int platformMenuItemId = menuBar->FindMenuItem (_("Advanced"),
MC _T("Platform Specific Example"));
CPPUNIT_ASSERT_MESSAGE ("Menu item ID 'platformMenuItem' not found",
platformMenuItemId != wxNOT_FOUND);
wxMenuItem *platformMenuItem = menuBar->FindItem (
platformMenuItemId);
CPPUNIT_ASSERT_MESSAGE ("Menu item 'platformMenuItem' not found",
platformMenuItem != NULL);
wxTst::EventSimulationHelper::SelectMenuItem (
platformMenuItemId, topFrame);
wxTst::WxGuiTestHelper::FlushEventQueue ();
wxWindow* wdw = topFrame->FindWindow(_T("platform_child"));
if (wdw == NULL)
wdw = wxWindow::FindWindowByName(_T("platform_child"));
CPPUNIT_ASSERT_MESSAGE("First Child not found", wdw != NULL);
wxMDIChildFrame* child1 = dynamic_cast<wxMDIChildFrame*>(wdw);
CPPUNIT_ASSERT_MESSAGE("Window isn't an MDI Child", child1 != NULL);
wxTst::WxGuiTestHelper::FlushEventQueue ();
interactive.ShowCurrentGui (_T(__FILE__), __LINE__);
wxTst::EventSimulationHelper::SelectMenuItem (
platformMenuItemId, topFrame);
wxTst::WxGuiTestHelper::FlushEventQueue ();
// interactive.ShowCurrentGui (_T(__FILE__), __LINE__);
wxMDIChildFrame* child2 = topFrame->GetActiveChild();
CPPUNIT_ASSERT_MESSAGE("Second child not found", child2 != NULL);
CPPUNIT_ASSERT_MESSAGE("Second child same as first ", child2 != child1);
child2->Close();
int derived_toolMenuItemId = menuBar->FindMenuItem (_("Advanced"),
MC _T("Custom Class Example"));
CPPUNIT_ASSERT_MESSAGE ("Menu item ID 'derived_toolMenuItem' not found",
derived_toolMenuItemId != wxNOT_FOUND);
wxMenuItem *derived_toolMenuItem = menuBar->FindItem (
derived_toolMenuItemId);
CPPUNIT_ASSERT_MESSAGE ("Menu item 'derived_toolMenuItem' not found",
derived_toolMenuItem != NULL);
wxTst::EventSimulationHelper::SelectMenuItem (
derived_toolMenuItemId, topFrame);
wxTst::WxGuiTestHelper::FlushEventQueue ();
wxWindow *custom_child =
wxWindow::FindWindowByName (_T("custom_class_child"));
CPPUNIT_ASSERT_MESSAGE ("Container window for button 'wxID_OK' not found",
custom_child != NULL);
// interactive.ShowCurrentGui (_T(__FILE__), __LINE__);
wxWindow *wxID_OKWdw4 = custom_child->FindWindow (XRCID("wxID_OK"));
CPPUNIT_ASSERT_MESSAGE ("Window for button 'wxID_OK' not found",
wxID_OKWdw4 != NULL);
wxTst::EventSimulationHelper::ClickButton (wxID_OKWdw4->GetId (),
wxID_OKWdw4);
wxTst::WxGuiTestHelper::FlushEventQueue ();
CPPUNIT_ASSERT_MESSAGE("OK Button didn't hide Mac Specific Dialog",
custom_child->IsShown() == false);
}
Источник: метод примера из wxGuiTesting