[BACK]Return to opt_c.c CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / src / tests / usr.bin / indent

File: [cvs.NetBSD.org] / src / tests / usr.bin / indent / opt_c.c (download)

Revision 1.2, Fri Nov 19 22:24:29 2021 UTC (2 years, 4 months ago) by rillig
Branch: MAIN
Changes since 1.1: +39 -1 lines

tests/indent: refine and extend tests

/* $NetBSD: opt_c.c,v 1.2 2021/11/19 22:24:29 rillig Exp $ */
/* $FreeBSD$ */

/*
 * Tests for the option '-c', which specifies the column in which the comments
 * to the right of the code start.
 */

#indent input
bool
is_prime(int n)
{
	if (n <= 3)
		return n >= 2; /* special case */
	if (n % 2 == 0)
		return false;				/* even numbers */
	return true;
}
#indent end

#indent run -c49
bool
is_prime(int n)
{
	if (n <= 3)
		return n >= 2;			/* special case */
	if (n % 2 == 0)
		return false;			/* even numbers */
	return true;
}
#indent end

/*
 * If the code is too wide to allow the comment in its preferred column, it is
 * nevertheless indented with a single tab, to keep multiple comments
 * vertically aligned.
 */
#indent run -c9
bool
is_prime(int n)
{
	if (n <= 3)
		return n >= 2;	/* special case */
	if (n % 2 == 0)
		return false;	/* even numbers */
	return true;
}
#indent end

/*
 * Usually, comments are aligned at a tabstop, but indent can also align them
 * at any other column.
 */
#indent run -c37
bool
is_prime(int n)
{
	if (n <= 3)
		return n >= 2;	    /* special case */
	if (n % 2 == 0)
		return false;	    /* even numbers */
	return true;
}
#indent end