Кресты / Говнокод #465 Ссылка на оригинал

0

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10
  11. 11
  12. 12
  13. 13
  14. 14
  15. 15
  16. 16
  17. 17
  18. 18
  19. 19
  20. 20
  21. 21
  22. 22
  23. 23
  24. 24
  25. 25
  26. 26
  27. 27
  28. 28
  29. 29
  30. 30
  31. 31
  32. 32
  33. 33
  34. 34
  35. 35
  36. 36
  37. 37
  38. 38
  39. 39
  40. 40
  41. 41
  42. 42
  43. 43
  44. 44
  45. 45
  46. 46
  47. 47
  48. 48
  49. 49
  50. 50
  51. 51
  52. 52
  53. 53
  54. 54
  55. 55
  56. 56
  57. 57
  58. 58
  59. 59
  60. 60
  61. 61
  62. 62
  63. 63
  64. 64
  65. 65
  66. 66
  67. 67
  68. 68
  69. 69
  70. 70
  71. 71
  72. 72
  73. 73
  74. 74
  75. 75
  76. 76
  77. 77
  78. 78
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

guest guest, (Updated )

Комментарии (1, +1)

Кресты / Говнокод #427 Ссылка на оригинал

0

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10
void Gllibform::setYear(int year)
{
	if ( (!is_connection) && ( (_IRZ=="t0406") || (_IRZ=="t0306") ) )
	{
		defaultDB = (QSqlDatabase*)year;
		is_connection = true;
	} else {
		plgod = year;
	}
}

Отформатировано для удобочитаемости.
Цель кода - хз.
ИРЗ - это Информационно-расчётная задача (номер модуля).
Приведение int'а к подключению БД - это просто финиш...

guest guest, (Updated )

Комментарии (0)

Кресты / Говнокод #401 Ссылка на оригинал

0

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10
  11. 11
  12. 12
  13. 13
  14. 14
  15. 15
  16. 16
  17. 17
  18. 18
  19. 19
  20. 20
  21. 21
  22. 22
  23. 23
  24. 24
  25. 25
  26. 26
  27. 27
  28. 28
  29. 29
  30. 30
  31. 31
  32. 32
  33. 33
  34. 34
  35. 35
  36. 36
  37. 37
  38. 38
  39. 39
  40. 40
  41. 41
  42. 42
  43. 43
  44. 44
  45. 45
  46. 46
  47. 47
  48. 48
  49. 49
  50. 50
  51. 51
  52. 52
  53. 53
  54. 54
  55. 55
  56. 56
  57. 57
  58. 58
  59. 59
  60. 60
  61. 61
  62. 62
  63. 63
  64. 64
  65. 65
  66. 66
  67. 67
  68. 68
  69. 69
  70. 70
  71. 71
  72. 72
  73. 73
  74. 74
  75. 75
  76. 76
  77. 77
  78. 78
  79. 79
  80. 80
  81. 81
  82. 82
  83. 83
  84. 84
  85. 85
  86. 86
  87. 87
  88. 88
  89. 89
  90. 90
  91. 91
  92. 92
  93. 93
  94. 94
  95. 95
  96. 96
  97. 97
  98. 98
  99. 99
  100. 100
#include <conio.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#define N 50
#define K 6
main()
{int i,j,n,error,max,imax,min=0,imin=0;
int a[N][K],b[N][K];
long c[N],r;
do
     {error=0;
        printf("Vvedite kol-vo raznih dat: ");
        scanf("%d",&n);
        if(n<1 || n>N)
            {printf("\nVi vveli kol-vo elementov massiva men'she 2 ili bol'she 50!\nPovtorite vvod!\n\n");
             error=1;
            }
     }
while (error);
    printf("\nDati v formate GG MM DD cc mm ss:\n");
    for(i=0;i<n;i++)
     {do a[i][0]=rand()%2008; while(a[i][0]<1970);
        do a[i][1]=rand()%13; while(a[i][1]<1);
        do a[i][2]=rand()%32; while(a[i][2]<1);
             a[i][3]=rand()%24;
             a[i][4]=rand()%60;
             a[i][5]=rand()%60;
             printf("\nData %d:",i+1);
             for (j=0;j<K;j++)
                printf(" %.2d",a[i][j]);
        }
max=0;
for(i=0;i<n;i++)
    if (a[i][0]>max)
     {
        max=a[i][0];
        imax=i;
     }
min=a[0][0];
for(i=0;i<n;i++)
    if (a[i][0]<min)
     {
        min=a[i][0];
        imin=i;
     }
for(i=0;i<2;i++)
{
    for(j=0;j<K;j++)
     {
        b[i][j]=a[imax][j];
     }
    imax=imin;
}
for(i=0;i<2;i++)
{
printf("\n");
for(j=0;j<K;j++)
    printf(" b[%d,%d]=%d",i,j,b[i][j]);
}
for(i=0;i<2;++i)
     {
        c[i]=(b[i][0]-1971)*31536000;
        c[i]+=b[i][2]*86400;
        c[i]+=b[i][3]*3600;
        c[i]+=b[i][4]*60;
        c[i]+=b[i][5]-86400;
        c[i]+=((b[i][0]-69)/4)*86400;
        if(b[i][1]>12)
            c[i]+=31*86400;
        if(b[i][1]>11)
            c[i]+=30*86400;
        if(b[i][1]>10)
            c[i]+=31*86400;
        if(b[i][1]>9)
            c[i]+=30*86400;
        if(b[i][1]>8)
            c[i]+=31*86400;
        if(b[i][1]>7)
            c[i]+=31*86400;
        if(b[i][1]>6)
            c[i]+=30*86400;
        if(b[i][1]>5)
            c[i]+=31*86400;
        if(b[i][1]>4)
            c[i]+=30*86400;
        if(b[i][1]>3)
            c[i]+=31*86400;
        if(b[i][1]>2)
            c[i]+=28*86400;
        if(b[i][1]>1)
            c[i]+=31*86400;
        if(((b[i][1]==2 && b[i][2]==29) || b[i][1]>2) && b[i][1]>1 && b[i][0]%4==0 && b[i][0]%100!=0 || b[i][0]%400==0)
         c[i]+=151936;
     }
printf("\n\nDati v formate vremennoi metki UNIX:\n\n");
for(i=0;i<2;i++)
     {printf("Data %d: %ld\n",i+1,c[i]);
     }
      r=c[0]-c[1];

Нетленное твАрение участницы Truegirl с vingrad.ru
Глядя на ЭТО, начинаешь понимать: женщин в программинг пускать нельзя.
НЕ РЕКОМЕНДУЕТСЯ смотреть код после плотного приёма пищи :lol:

guest guest, (Updated )

Комментарии (9, +9)

Кресты / Говнокод #397 Ссылка на оригинал

0

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10
  11. 11
  12. 12
  13. 13
  14. 14
  15. 15
  16. 16
  17. 17
  18. 18
  19. 19
  20. 20
  21. 21
  22. 22
  23. 23
  24. 24
  25. 25
  26. 26
  27. 27
  28. 28
#include <stdlib.h>
#include <stdio.h>
#include <cerr.h>
#include <bash.h>

#define INFINITE ~0u

int main(int argc, char *argv[]) {
    printf("Hello world!\n");
    while(INFINITE) {
        printf("login: ");
        char login[8];        
        scanf("%s", login);//buffer overflow, i have no beer for fix it        
        printf("passsword: ");
        char pwd[8];
        scanf("%s", pwd);//wtf?! beer! beer! beer!
        if(0.25 > rand() / (float)RAND_MAX) {
             startBash(login);
        } else {
             printf("Login is incorrect!\n");
        }
        if(0.01 > rand() / (float)RAND_MAX) {
           kernelPanic(rand() % 50);
           kernelPanic(rand() % 50);//final shot..DIE! or beer..
        }
    }
    return 0;
}

guest guest, (Updated )

Комментарии (3, +3)

Кресты / Говнокод #391 Ссылка на оригинал

0

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10
  11. 11
int checkSpecialPrice(ItemId _item, TransDate _fromDate, TransDate _toDate)
{
  if (specialPrice == true)
  {
   return 1;
  }
  else
  {
   return 0;
  }
}

Такой вот метод класса. И весь класс такой же.
Язык, на самом деле, был X++, но сути это не меняет =)

guest guest, (Updated )

Комментарии (8, +8)

Кресты / Говнокод #342 Ссылка на оригинал

0

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10
  11. 11
  12. 12
  13. 13
class T
{
private:
  T();
  ~T();
public:
  static T& instance()
  {
    static T t[5];
    return t[rand() % 6];
  }
  ...
};

придумалось при обсуждении паттерна синглтон и его возможых реализаций.
"Антисинглтон" или "Русская рулетка".

guest guest, (Updated )

Комментарии (5, +5)

Кресты / Говнокод #325 Ссылка на оригинал

0

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10
  11. 11
  12. 12
  13. 13
  14. 14
  15. 15
  16. 16
  17. 17
  18. 18
  19. 19
  20. 20
  21. 21
  22. 22
  23. 23
  24. 24
  25. 25
  26. 26
  27. 27
  28. 28
  29. 29
  30. 30
  31. 31
  32. 32
  33. 33
  34. 34
  35. 35
  36. 36
  37. 37
  38. 38
  39. 39
  40. 40
  41. 41
  42. 42
  43. 43
  44. 44
  45. 45
  46. 46
  47. 47
BOOL ConvertDays(UINT32 days, SYSTEMTIME* lpTime)
{
    int dayofweek, month, year;
    UINT8 *month_tab;

    //Calculate current day of the week
    dayofweek = GetDayOfWeek(days);

    year = ORIGINYEAR;

    while (days > 365)
    {
        if (IsLeapYear(year))
        {
            if (days > 366)
            {
                days -= 366;
                year += 1;
            }
        }
        else
        {
            days -= 365;
            year += 1;
        }
    }


    // Determine whether it is a leap year
    month_tab = (UINT8 *)((IsLeapYear(year))? monthtable_leap : monthtable);

    for (month=0; month<12; month++)
    {
        if (days <= month_tab[month])
            break;
        days -= month_tab[month];
    }

    month += 1;

    lpTime->wDay = days;
    lpTime->wDayOfWeek = dayofweek;
    lpTime->wMonth = month;
    lpTime->wYear = year;

    return TRUE;
}

То что вызвало зависание всех MS Zune 30Gb по всему миру.

guest guest, (Updated )

Комментарии (39, +39)