がんばって英語で書くブログ
英語勉強中なので、ブログも英語で書こうかと。
スポンサーサイト
上記の広告は1ヶ月以上更新のないブログに表示されています。
新しい記事を書く事で広告が消せます。

fried potato
I ride a bus tonight. that time someone who brought fried potato so the bus smells of fried potato that smells make me hungrily:-( that fried potato must be mcdonald's fried potato.
Umm I haven't eaten it. I wanna eat it:-)

スポンサーサイト

テーマ:英語日記 - ジャンル:学問・文化・芸術

fluxbox1.0 rc
I downloaded fluxbox1.0 rc and made a debian package.
it's so far so good:-)

% ls
fluxbox-1.0rc.tar.gz
% apt-get source fluxbox
% cd fluxbox-0.9.14
% uupdate ../fluxbox-1.0rc.tar.gz 1.0rc1
% cd ../fluxbox-1.0rc1
(I'd gotten ftbfs so I write pacth)
% pdebuild

this is patch

diff -urNad fluxbox-1.0rc1~/src/Resources.cc fluxbox-1.0rc1/src/Resources.cc
--- fluxbox-1.0rc1~/src/Resources.cc 2006-06-22 21:53:03.000000000 +0900
+++ fluxbox-1.0rc1/src/Resources.cc 2006-06-22 22:06:45.000000000 +0900
@@ -43,8 +43,6 @@
//-----------------------------------------------------------------
namespace FbTk {

-namespace FbTk {
-
template<>
void FbTk::Resource<int>::
setFromString(const char* strval) {
diff -urNad fluxbox-1.0rc1~/src/ScreenResources.cc fluxbox-1.0rc1/src/ScreenResources.cc
--- fluxbox-1.0rc1~/src/ScreenResources.cc 2006-06-22 21:53:03.000000000 +0900
+++ fluxbox-1.0rc1/src/ScreenResources.cc 2006-06-22 22:05:23.000000000 +0900
@@ -31,8 +31,6 @@

namespace FbTk {

-namespace FbTk {
-
template <>
string FbTk::Resource<FbTk::MenuTheme::MenuMode>::getString() const {
switch (*(*this)) {

テーマ:UNIX/Linux - ジャンル:コンピュータ

first day
I went to work. I haven't work for 1 year so I'm bit tired cuz I ride a train and a bus:-(.
I have a training 1 week then I'm gonna into some project.
I'm a softwere engineer.

when I quit programmer(it's also softwere engineer) I didn't wanna be softwere engineer anymore, because I was always busy but computer technology is interesting. so I
chose it.

btw I'm looking for new apartment. I wanna live near a station.

テーマ:英語日記 - ジャンル:学問・文化・芸術

super cows power
% LANG=C aptitude -v moo
There really are no Easter Eggs in this program.
% LANG=C aptitude -vv moo
Didn't I already tell you that there are no Easter Eggs in this program?
% LANG=C aptitude -vvv moo
Stop it!
% LANG=C aptitude -vvvv moo
Okay, okay, if I give you an Easter Egg, will you go away?
% LANG=C aptitude -vvvvv moo
All right, you win.

/----\
-------/ \
/ \
/ |
-----------------/ --------\
----------------------------------------------

% LANG=C aptitude -vvvvvv moo
What is it? It's an elephant being eaten by a snake, of course.
%

テーマ:UNIX/Linux - ジャンル:コンピュータ

new job
I got new job:-) so I'm gonna be busy and I'm gonna be broke:-( cuz, I have to buy new suit, shirts and so on.

テーマ:英語日記 - ジャンル:学問・文化・芸術

unit test for c
simple unit test framework


/*
* c_unit_test.h
* simpe unit test framework for C
*
* Copyright (C) 2006 foobar <storm_of_the_death at yahoo.co.jp>
*
* GNU General Public License (GPL) version 2.
*/
#ifndef C_UNIT_TEST_H
#define C_UNIT_TEST_H 1

#include <stdio.h>
#include <string.h>

typedef int test_result_t;

#define TEST_OK 1
#define TEST_FAIL 0

#ifndef N_C_UNIT_TEST
#define assert_NULL(result) c_assert_NULL(result, __FILE__, __LINE__, __FUNCTION__)

#define assert_char(expected, result) assert_long((long) expected, (long) result)
#define assert_uchar(expected, result) assert_ulong((unsigned long) expected, (unsigned long) result)

#define assert_short(expected, result) assert_long((long) expected, (long) result)
#define assert_ushort(expected, result) assert_ulong((unsigned long) expected, (unsigned long) result)

#define assert_int(expected, result) assert_long((long) expected, (long) result)
#define assert_uint(expected, result) assert_ulong((unsigned long) expected, (unsigned long) result)

#define assert_long(expected, result) c_assert_long(expected, result, __FILE__, __LINE__, __FUNCTION__)
#define assert_ulong(expected, result) c_assert_ulong(expected, result, __FILE__, __LINE__, __FUNCTION__)

#define assert_float(expected, result) assert_double((double) expected, (double) result)
#define assert_double(expected, result) c_assert_double(expected, result, __FILE__, __LINE__, __FUNCTION__)

#define assert_equal(expected, result) c_assert_equal(expected, result, __FILE__, __LINE__, __FUNCTION__)

#else /* N_C_UNIT_TEST */

#define assert_NULL(result) /* none */

#define assert_char(expected, result) /* none */
#define assert_uchar(expected, result) /* none */

#define assert_short(expected, result) /* none */
#define assert_ushort(expected, result) /* none */

#define assert_int(expected, result) /* none */
#define assert_uint(expected, result) /* none */

#define assert_long(expected, result) /* none */
#define assert_ulong(expected, result) /* none */

#define assert_float(expected, result) /* none */
#define assert_double(expected, result) /* none */

#define assert_equal(expected, result) /* none */

#endif /* N_C_UNIT_TEST */

static inline test_result_t c_assert_NULL(void *result, char *file, int line, char *func)
{
if (result == NULL) {
printf("%s:%d: %s: Assertion: result expected is NULL\n", file, line, func);
return TEST_FAIL;
}

return TEST_OK;
}

static inline test_result_t c_assert_long(long expected, long result, char *file, int line, char *func)
{
if (expected != result) {
printf("%s:%d: %s: Assertion: expected is %ld but result is %ld\n", file, line, func, expected, result);
return TEST_FAIL;
}

return TEST_OK;
}

static inline test_result_t c_assert_ulong(unsigned long expected, unsigned long result, char *file, int line, char *func)
{
if (expected != result) {
printf("%s:%d: %s: Assertion: expected is %ld but result is %ld\n", file, line, func, expected, result);
return TEST_FAIL;
}

return TEST_OK;
}

static inline test_result_t c_assert_double(double expected, double result, char *file, int line, char *func)
{
if (expected != result) {
printf("%s:%d: %s: Assertion: expected is %f but result is %f\n", file, line, func, expected, result);
return TEST_FAIL;
}

return TEST_OK;
}

static inline test_result_t c_assert_equal(char *expected, char *result, char *file, int line, char *func)
{
if (strcmp(expected, result)) {
printf("%s:%d: %s: Assertion: expected is %s but result is %s\n", file, line, func, expected, result);
return TEST_FAIL;
}

return TEST_OK;
}

#endif /* C_UNIT_TEST_H */



How to use? like this.

I wanna test this file.
#include <stdio.h>

int add(int x, int y)
{
return x + y;
}

test code is this.
sample_test.c
#include "c_unit_test.h"

void test_add(void)
{
int ret;

/* 3 + 5 = 8 */
ret = add(3, 5);
assert_int(8, ret);

/* -1 + -1 = -2 */
ret = add(-1, -1);
assert_int(-2, ret);
}

int main(int argc, char **argv)
{
test_add();
return 0;
}

% gcc sample.c sample_test.c -o sample
% ./sample

if test is fail, output will be this.
sample_test.c:10: test_add: Assertion: value is 8 but result is 9
sample_test.c:14: test_add: Assertion: value is -2 but result is -1

テーマ:プログラミング - ジャンル:コンピュータ

kill time
I saw this page.
it's just for kill time:-)


#include <stdio.h>
#include <stdlib.h>

static inline long even(long x)
{
return x / 2;
}

static inline long odd(long x)
{
return 3 * x + 1;
}

/**
* if x is an odd number, it'll return 1
* if x isn't an odd number, it'll return 0
*/
static inline long is_odd(long x)
{
return ((x % 2) != 0);
}

static void start(long x)
{
long cnt = 0;

while (x != 1) {
if (is_odd(x))
x = odd(x);
else
x = even(x);

printf("%ld,", x);

cnt++;

if (cnt == 10) {
cnt = 0;
putchar('\n');
}


}

putchar('\n');
}

static void usage(char *arg)
{
fprintf(stderr, "usage %s [num]\n", arg);
exit(-1);
}

int main(int argc, char **argv)
{
long x;

if (argc != 2)
usage(argv[0]);

x = atol(argv[1]);

start(x);

return 0;

}



this is exsample log.
% gcc 3x_plus_1.c -Wall
% ./a.out 1000
500,250,125,376,188,94,47,142,71,214,
107,322,161,484,242,121,364,182,91,274,
137,412,206,103,310,155,466,233,700,350,
175,526,263,790,395,1186,593,1780,890,445,
1336,668,334,167,502,251,754,377,1132,566,
283,850,425,1276,638,319,958,479,1438,719,
2158,1079,3238,1619,4858,2429,7288,3644,1822,911,
2734,1367,4102,2051,6154,3077,9232,4616,2308,1154,
577,1732,866,433,1300,650,325,976,488,244,
122,61,184,92,46,23,70,35,106,53,
160,80,40,20,10,5,16,8,4,2,
1,

テーマ:英語日記 - ジャンル:学問・文化・芸術

June
May was finish, weather is gonna be *real* rain season in few weeks. I quite like rain day so rain season is not bad. but, I'm not good for walking at rain day. stay at home is okay but go out somewhere is bad.

it's interesting



テーマ:英語日記 - ジャンル:学問・文化・芸術



上記広告は1ヶ月以上更新のないブログに表示されています。新しい記事を書くことで広告を消せます。